From 1c744a5070d2fe949f73f1db3c6b192613b3a18a Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Sat, 25 Dec 2021 14:58:53 +0500 Subject: [PATCH] new set command --- commands/Administration/set.js | 51 +++++++++++++++++++++++++ languages/ru-RU/administration/set.json | 13 +++++++ 2 files changed, 64 insertions(+) create mode 100644 commands/Administration/set.js create mode 100644 languages/ru-RU/administration/set.json diff --git a/commands/Administration/set.js b/commands/Administration/set.js new file mode 100644 index 00000000..35a8e611 --- /dev/null +++ b/commands/Administration/set.js @@ -0,0 +1,51 @@ +const Command = require("../../base/Command.js"); + +class Set extends Command { + constructor (client) { + super(client, { + name: "debug", + dirname: __dirname, + enabled: true, + guildOnly: true, + aliases: [], + memberPermissions: [ "MANAGE_GUILD" ], + botPermissions: [ "SEND_MESSAGES" ], + nsfw: false, + ownerOnly: false, + cooldown: 3000 + }); + } + + async run (message, args, data) { + const status = args[0]; + if (!status || !["level", "xp", "credits", "bank"].includes(status)) return message.error("administration/set:NO_STATUS"); + + const member = await this.client.resolveMember(args[1], message.guild); + if (!member) return message.error("administration/set:INVALID_MEMBER"); + if (member.user.bot) return message.error("administration/set:BOT_USER"); + + const number = args[2]; + if (!number || isNaN(number) || parseInt(number, 10) <= 0) return message.error("administration/set:INVALID_AMOUNT"); + const amount = Math.ceil(parseInt(number, 10)); + + const memberData = await this.client.findOrCreateMember({ id: member.id, guildID: message.guild.id }); + + if (status === "level") { + memberData.level = parseInt(amount, 10); + memberData.save(); + } else if (status === "xp") { + memberData.exp = parseInt(amount, 10); + memberData.save(); + } else if (status === "credits") { + memberData.money = parseInt(amount, 10); + memberData.save(); + } else if (status === "bank") { + memberData.bankSold = parseInt(amount, 10); + memberData.save(); + } + + message.success("administration/set:SUCCESS_" + status.toUpperCase() , { username: member.user.tag, amount }); + } +}; + +module.exports = Set; \ No newline at end of file diff --git a/languages/ru-RU/administration/set.json b/languages/ru-RU/administration/set.json new file mode 100644 index 00000000..0eab8dd2 --- /dev/null +++ b/languages/ru-RU/administration/set.json @@ -0,0 +1,13 @@ +{ + "DESCRIPTION": "Изменить пользователю опыт, уровень, кредиты или банк !", + "USAGE": "{{prefix}}set [level/xp/credits/bank] [@пользователь] [значение]", + "EXAMPLES": "{{prefix}}set level @Jonny_Bro#4226 10", + "INVALID_MEMBER": "Вы должны упомянуть пользователя!", + "NO_STATUS": "Выберите действие: `level`, `xp`, `credits` или `bank`", + "BOT_USER": "У ботов нет профиля!", + "INVALID_AMOUNT": "Укажите новое значение!", + "SUCCESS_LEVEL": "Уровень пользователя **{{username}}** изменён на **{{amount}}**!", + "SUCCESS_XP": "XP пользователя **{{username}}** изменён на **{{amount}}**!", + "SUCCESS_CREDITS": "Кредиты пользователя **{{username}}** изменены на **{{amount}}**!", + "SUCCESS_BANK": "Банк пользователя **{{username}}** изменён на **{{amount}}**!" +} \ No newline at end of file