JaBa/commands/Administration/set.js

57 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-12-25 14:58:53 +05:00
const Command = require("../../base/Command.js");
class Set extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-25 14:58:53 +05:00
super(client, {
2021-12-25 14:59:31 +05:00
name: "set",
2021-12-25 14:58:53 +05:00
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
2021-12-26 19:29:37 +05:00
memberPermissions: ["MANAGE_GUILD"],
botPermissions: ["SEND_MESSAGES"],
2021-12-25 14:58:53 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 2000
2021-12-25 14:58:53 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-25 14:58:53 +05:00
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];
2021-12-29 02:27:48 +05:00
if (!number || isNaN(number) || parseInt(number, 10) < 0) return message.error("administration/set:INVALID_AMOUNT");
2021-12-25 14:58:53 +05:00
const amount = Math.ceil(parseInt(number, 10));
2021-12-26 19:29:37 +05:00
const memberData = await this.client.findOrCreateMember({
id: member.id,
guildID: message.guild.id
});
2021-12-25 14:58:53 +05:00
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();
}
2021-12-26 19:29:37 +05:00
message.success("administration/set:SUCCESS_" + status.toUpperCase(), {
username: member.user.tag,
amount
});
2021-12-25 14:58:53 +05:00
}
};
module.exports = Set;