JaBa/commands/Economy/deposit.js

43 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Deposit extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "deposit",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["bank", "dep"],
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.money, 10) > 0)) return message.error("economy/deposit:NO_CREDIT");
if (args[0] === "all") {
amount = parseInt(data.memberData.money, 10);
} else {
if (isNaN(amount) || parseInt(amount, 10) < 1) return message.error("economy/deposit:MISSING_AMOUNT");
amount = parseInt(amount, 10);
};
2022-01-04 00:35:11 +05:00
if (data.memberData.money < amount) return message.error("economy/deposit:NOT_ENOUGH_CREDIT", { money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` });
2021-12-10 21:39:54 +05:00
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/deposit:SUCCESS", {
money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`
2021-12-26 19:29:37 +05:00
});
2021-12-10 21:39:54 +05:00
}
};
module.exports = Deposit;