JaBa/commands/Owner/debug.js

277 lines
7.9 KiB
JavaScript
Raw Permalink Normal View History

const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Debug extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("debug")
.setDescription(client.translate("owner/debug:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("owner/debug:DESCRIPTION", null, "uk-UA"),
ru: client.translate("owner/debug:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
2023-07-05 00:58:06 +05:00
.addSubcommand(subcommand =>
subcommand
.setName("set")
.setDescription(client.translate("owner/debug:SET"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("owner/debug:SET", null, "uk-UA"),
ru: client.translate("owner/debug:SET", null, "ru-RU"),
})
2023-07-05 00:58:06 +05:00
.addStringOption(option =>
option
.setName("type")
.setDescription(client.translate("owner/debug:TYPE"))
.setDescriptionLocalizations({
uk: client.translate("owner/debug:TYPE", null, "uk-UA"),
ru: client.translate("owner/debug:TYPE", null, "ru-RU"),
})
.setRequired(true)
.setChoices(
{ name: client.translate("common:LEVEL"), value: "level" },
{ name: client.translate("common:XP"), value: "xp" },
{ name: client.translate("common:CREDITS"), value: "credits" },
{ name: client.translate("economy/transactions:BANK"), value: "bank" },
{ name: client.translate("common:REP"), value: "rep" },
),
)
.addUserOption(option =>
option
.setName("user")
.setDescription(client.translate("common:USER"))
.setDescriptionLocalizations({
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true),
)
.addIntegerOption(option =>
option
.setName("int")
.setDescription(client.translate("common:INT"))
.setDescriptionLocalizations({
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true),
),
)
2023-07-05 00:58:06 +05:00
.addSubcommand(subcommand =>
subcommand
.setName("add")
.setDescription(client.translate("owner/debug:ADD"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("owner/debug:ADD", null, "uk-UA"),
ru: client.translate("owner/debug:ADD", null, "ru-RU"),
})
2023-07-05 00:58:06 +05:00
.addStringOption(option =>
option
.setName("type")
.setDescription(client.translate("owner/debug:TYPE"))
.setDescriptionLocalizations({
uk: client.translate("owner/debug:TYPE", null, "uk-UA"),
ru: client.translate("owner/debug:TYPE", null, "ru-RU"),
})
.setRequired(true)
.setChoices(
{ name: client.translate("common:LEVEL"), value: "level" },
{ name: client.translate("common:XP"), value: "xp" },
{ name: client.translate("common:CREDITS"), value: "credits" },
{ name: client.translate("economy/transactions:BANK"), value: "bank" },
{ name: client.translate("common:REP"), value: "rep" },
),
)
.addUserOption(option =>
option
.setName("user")
.setDescription(client.translate("common:USER"))
.setDescriptionLocalizations({
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true),
)
.addIntegerOption(option =>
option
.setName("int")
.setDescription(client.translate("common:INT"))
.setDescriptionLocalizations({
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true),
),
),
dirname: __dirname,
ownerOnly: true,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
2022-10-03 20:24:49 +05:00
async execute(client, interaction) {
2022-08-08 18:19:56 +05:00
const command = interaction.options.getSubcommand();
2022-08-08 18:19:56 +05:00
if (command === "set") {
const type = interaction.options.getString("type"),
int = interaction.options.getInteger("int");
2022-08-03 21:13:22 +05:00
const member = interaction.options.getMember("user");
2022-08-08 18:19:56 +05:00
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
2023-10-30 21:45:10 +05:00
const userData = await client.findOrCreateUser(member.id),
memberData = await client.findOrCreateMember({
id: member.id,
guildId: interaction.guildId,
});
switch (type) {
case "level": {
2022-08-09 23:48:33 +05:00
memberData.level = int;
memberData.markModified("level");
2022-08-09 23:48:33 +05:00
await memberData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
case "xp": {
2022-08-09 23:48:33 +05:00
memberData.exp = int;
memberData.markModified("exp");
2022-08-09 23:48:33 +05:00
await memberData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
case "credits": {
2022-08-09 23:48:33 +05:00
memberData.money = int;
memberData.markModified("money");
2022-08-09 23:48:33 +05:00
await memberData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
case "bank": {
2022-08-09 23:48:33 +05:00
memberData.bankSold = int;
memberData.markModified("bankSold");
2022-08-09 23:48:33 +05:00
await memberData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
case "rep": {
2022-08-09 23:48:33 +05:00
userData.rep = int;
userData.markModified("rep");
2022-08-09 23:48:33 +05:00
await userData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
}
} else {
const type = interaction.options.getString("type"),
int = interaction.options.getInteger("int");
const member = interaction.options.getMember("target");
2022-08-08 18:19:56 +05:00
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
2023-10-30 21:45:10 +05:00
const userData = await client.findOrCreateUser(member.id),
memberData = await client.findOrCreateMember({
id: member.id,
guildId: interaction.guildId,
});
switch (type) {
case "level": {
2022-08-09 23:48:33 +05:00
memberData.level += int;
memberData.markModified("level");
2022-08-09 23:48:33 +05:00
await memberData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
case "xp": {
2022-08-09 23:48:33 +05:00
memberData.exp += int;
memberData.markModified("exp");
2022-08-09 23:48:33 +05:00
await memberData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
case "credits": {
2022-08-09 23:48:33 +05:00
memberData.money += int;
memberData.markModified("money");
2022-08-09 23:48:33 +05:00
await memberData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
case "bank": {
2022-08-09 23:48:33 +05:00
memberData.bankSold += int;
memberData.markModified("bankSold");
2022-08-09 23:48:33 +05:00
await memberData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
case "rep": {
2022-08-09 23:48:33 +05:00
userData.rep += int;
userData.markModified("rep");
2022-08-09 23:48:33 +05:00
await userData.save();
2023-07-03 19:30:47 +05:00
2022-08-09 23:48:33 +05:00
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(),
amount: int,
}, { ephemeral: true });
}
}
}
}
}
2023-07-05 00:58:06 +05:00
module.exports = Debug;