2021-12-10 21:39:54 +05:00
|
|
|
const Command = require("../../base/Command.js");
|
|
|
|
|
|
|
|
class Withdraw extends Command {
|
2021-12-26 19:29:37 +05:00
|
|
|
constructor(client) {
|
2021-12-10 21:39:54 +05:00
|
|
|
super(client, {
|
|
|
|
name: "withdraw",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
2021-12-26 19:29:37 +05:00
|
|
|
aliases: ["wd"],
|
2021-12-10 21:39:54 +05:00
|
|
|
memberPermissions: [],
|
2021-12-26 19:29:37 +05:00
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
|
2021-12-10 21:39:54 +05:00
|
|
|
nsfw: false,
|
|
|
|
ownerOnly: false,
|
|
|
|
cooldown: 1000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-26 19:29:37 +05:00
|
|
|
async run(message, args, data) {
|
2021-12-10 21:39:54 +05:00
|
|
|
let amount = args[0];
|
|
|
|
|
|
|
|
if (!(parseInt(data.memberData.bankSold, 10) > 0)) return message.error("economy/withdraw:NO_CREDIT");
|
|
|
|
|
|
|
|
|
|
|
|
if (args[0] === "all") {
|
|
|
|
amount = parseInt(data.memberData.bankSold, 10);
|
|
|
|
} else {
|
2021-12-26 19:29:37 +05:00
|
|
|
if (isNaN(amount) || parseInt(amount, 10) < 1) return message.error("economy/withdraw:MISSING_AMOUNT");
|
2021-12-10 21:39:54 +05:00
|
|
|
amount = parseInt(amount, 10);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (data.memberData.bankSold < amount) return message.error("economy/withdraw:NOT_ENOUGH", { money: amount });
|
|
|
|
|
|
|
|
data.memberData.money = data.memberData.money + amount;
|
|
|
|
data.memberData.bankSold = data.memberData.bankSold - amount;
|
|
|
|
data.memberData.save();
|
|
|
|
|
2021-12-26 19:29:37 +05:00
|
|
|
message.success("economy/withdraw:SUCCESS", {
|
|
|
|
money: amount
|
|
|
|
});
|
2021-12-10 21:39:54 +05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Withdraw;
|