JaBa/commands/Owner/debug.js

95 lines
2.7 KiB
JavaScript
Raw Normal View History

2021-12-25 15:14:13 +05:00
const Command = require("../../base/Command.js");
class Debug extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-25 15:14:13 +05:00
super(client, {
name: "debug",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES"],
2021-12-25 15:14:13 +05:00
nsfw: false,
ownerOnly: true,
cooldown: 3000
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-25 15:14:13 +05:00
const action = args[0];
2021-12-25 15:18:09 +05:00
if (!action || !["set", "add"].includes(action)) return message.error("owner/debug:NO_ACTION");
2021-12-25 15:14:13 +05:00
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));
2021-12-26 19:29:37 +05:00
const memberData = await this.client.findOrCreateMember({
id: member.id,
guildID: message.guild.id
});
2021-12-25 15:14:13 +05:00
2021-12-25 15:27:35 +05:00
var newValue = 0;
2021-12-25 15:17:25 +05:00
if (action === "set") {
2021-12-25 15:27:35 +05:00
newValue = parseInt(amount, 10);
2021-12-25 15:17:25 +05:00
if (status === "level") {
2021-12-25 15:27:35 +05:00
memberData.level = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
} else if (status === "xp") {
2021-12-25 15:27:35 +05:00
memberData.exp = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
} else if (status === "rep") {
2021-12-25 15:27:35 +05:00
memberData.rep = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
} else if (status === "credits") {
2021-12-25 15:27:35 +05:00
memberData.money = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
} else if (status === "bank") {
2021-12-25 15:27:35 +05:00
memberData.bankSold = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
2021-12-25 15:27:35 +05:00
};
2021-12-29 02:05:05 +05:00
message.success("owner/debug:SUCCESS_" + status.toUpperCase(), {
2021-12-26 19:29:37 +05:00
username: member.user.tag,
amount
});
2021-12-25 15:17:25 +05:00
} else if (action === "add") {
if (status === "level") {
2021-12-25 15:27:35 +05:00
newValue = memberData.level + parseInt(amount, 10);
memberData.level = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
} else if (status === "xp") {
2021-12-25 15:27:35 +05:00
newValue = memberData.exp + parseInt(amount, 10);
memberData.exp = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
} else if (status === "rep") {
2021-12-25 15:27:35 +05:00
newValue = memberData.rep + parseInt(amount, 10);
memberData.rep = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
} else if (status === "credits") {
2021-12-25 15:27:35 +05:00
newValue = memberData.money + parseInt(amount, 10);
memberData.money = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
} else if (status === "bank") {
2021-12-25 15:27:35 +05:00
newValue = memberData.bankSold + parseInt(amount, 10);
memberData.bankSold = newValue;
2021-12-25 15:17:25 +05:00
memberData.save();
2021-12-25 15:27:35 +05:00
};
2021-12-25 15:14:13 +05:00
2021-12-26 19:29:37 +05:00
message.success("owner/debug:SUCCESS_" + status.toUpperCase(), {
username: member.user.tag,
amount: newValue
});
2021-12-25 15:27:35 +05:00
};
2021-12-25 15:14:13 +05:00
}
};
module.exports = Debug;