JaBa/commands/Owner/debug.js

100 lines
2.7 KiB
JavaScript
Raw Normal View History

const Command = require("../../base/Command");
2022-01-04 02:18:28 +05:00
class Debug extends Command {
constructor(client) {
super(client, {
name: "debug",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["deb"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES"],
nsfw: false,
ownerOnly: true,
cooldown: 3000
});
}
2022-01-13 00:26:23 +05:00
async run(message, args) {
2022-01-04 02:18:28 +05:00
const action = args[0];
if (!action || !["set", "add"].includes(action)) return message.error("owner/debug:NO_ACTION");
const status = args[1];
if (!status || !["level", "xp", "credits", "bank", "rep"].includes(status)) return message.error("owner/debug:NO_STATUS");
const member = await this.client.resolveMember(args[2], message.guild);
if (!member) return message.error("owner/debug:INVALID_MEMBER");
if (member.user.bot) return message.error("owner/debug:BOT_USER");
const number = args[3];
if (!number || isNaN(number)) return message.error("owner/debug:INVALID_AMOUNT");
const amount = Math.ceil(parseInt(number, 10));
const memberData = await this.client.findOrCreateMember({
id: member.id,
guildID: message.guild.id
});
2022-01-11 16:50:31 +05:00
const userData = await this.client.findOrCreateUser({
id: member.id,
});
2022-01-17 13:36:55 +05:00
let newValue = 0;
2022-01-04 02:18:28 +05:00
if (action === "set") {
newValue = parseInt(amount, 10);
if (status === "level") {
memberData.level = newValue;
memberData.save();
} else if (status === "xp") {
memberData.exp = newValue;
memberData.save();
} else if (status === "rep") {
2022-01-11 16:50:31 +05:00
userData.rep = newValue;
userData.save();
2022-01-04 02:18:28 +05:00
} else if (status === "credits") {
memberData.money = newValue;
memberData.save();
} else if (status === "bank") {
memberData.bankSold = newValue;
memberData.save();
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
message.success("owner/debug:SUCCESS_" + status.toUpperCase(), {
username: member.user.tag,
amount
});
} else if (action === "add") {
if (status === "level") {
newValue = memberData.level + parseInt(amount, 10);
memberData.level = newValue;
memberData.save();
} else if (status === "xp") {
newValue = memberData.exp + parseInt(amount, 10);
memberData.exp = newValue;
memberData.save();
} else if (status === "rep") {
2022-01-11 16:50:31 +05:00
newValue = userData.rep + parseInt(amount, 10);
userData.rep = newValue;
userData.save();
2022-01-04 02:18:28 +05:00
} else if (status === "credits") {
newValue = memberData.money + parseInt(amount, 10);
memberData.money = newValue;
memberData.save();
} else if (status === "bank") {
newValue = memberData.bankSold + parseInt(amount, 10);
memberData.bankSold = newValue;
memberData.save();
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
message.success("owner/debug:SUCCESS_" + status.toUpperCase(), {
username: member.user.tag,
amount: newValue
});
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
}
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
module.exports = Debug;