2023-07-03 21:13:08 +05:00
|
|
|
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
2022-08-08 18:19:56 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Set extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-08-08 18:19:56 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("set")
|
|
|
|
.setDescription(client.translate("administration/set:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("administration/set:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/set:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2023-07-03 21:13:08 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
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" },
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.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),
|
|
|
|
),
|
2022-08-08 18:19:56 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-08 18:19:56 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-08 18:19:56 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-08 18:19:56 +05:00
|
|
|
*/
|
2022-10-03 20:24:49 +05:00
|
|
|
async execute(client, interaction) {
|
2023-01-09 01:39:13 +05:00
|
|
|
const type = interaction.options.getString("type"),
|
|
|
|
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 });
|
2022-10-03 20:21:42 +05:00
|
|
|
|
2022-10-03 20:24:49 +05:00
|
|
|
const memberData = await client.findOrCreateMember({
|
2022-10-03 20:21:42 +05:00
|
|
|
id: member.id,
|
2022-12-15 21:02:38 +05:00
|
|
|
guildId: interaction.guildId,
|
2022-08-09 23:48:33 +05:00
|
|
|
});
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2022-08-08 18:19:56 +05:00
|
|
|
const int = interaction.options.getInteger("int");
|
|
|
|
if (int < 0) return interaction.error("administration/set:INVALID_NUMBER", null, { ephemeral: true });
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case "level": {
|
2022-08-09 23:48:33 +05:00
|
|
|
memberData.level = int;
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2023-10-31 22:24:40 +05:00
|
|
|
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()}`, {
|
2023-03-26 18:31:19 +05:00
|
|
|
user: member.toString(),
|
2022-12-15 21:02:38 +05:00
|
|
|
amount: int,
|
2022-08-08 18:19:56 +05:00
|
|
|
}, { ephemeral: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
case "xp": {
|
2022-08-09 23:48:33 +05:00
|
|
|
memberData.exp = int;
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2023-10-31 22:24:40 +05:00
|
|
|
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()}`, {
|
2023-03-26 18:31:19 +05:00
|
|
|
user: member.toString(),
|
2022-12-15 21:02:38 +05:00
|
|
|
amount: int,
|
2022-08-08 18:19:56 +05:00
|
|
|
}, { ephemeral: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
case "credits": {
|
2022-08-09 23:48:33 +05:00
|
|
|
memberData.money = int;
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2023-10-31 22:24:40 +05:00
|
|
|
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()}`, {
|
2023-03-26 18:31:19 +05:00
|
|
|
user: member.toString(),
|
2022-12-15 21:02:38 +05:00
|
|
|
amount: int,
|
2022-08-08 18:19:56 +05:00
|
|
|
}, { ephemeral: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
case "bank": {
|
2022-08-09 23:48:33 +05:00
|
|
|
memberData.bankSold = int;
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2023-10-31 22:24:40 +05:00
|
|
|
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()}`, {
|
2023-03-26 18:31:19 +05:00
|
|
|
user: member.toString(),
|
2022-12-15 21:02:38 +05:00
|
|
|
amount: int,
|
2022-08-08 18:19:56 +05:00
|
|
|
}, { ephemeral: true });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Set;
|