add money
This commit is contained in:
2 files changed
+88
-1
No files matched your search
@@ -0,0 +1,87 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "add-monet",
|
||||||
|
description: "change the starting balance for the server",
|
||||||
|
usage: "[user] [amount]",
|
||||||
|
permissions: {
|
||||||
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||||
|
member: ["MANAGE_GUILD"],
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "user",
|
||||||
|
description: "user to give money",
|
||||||
|
value: "user",
|
||||||
|
type: 6,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "amount",
|
||||||
|
description: "the amount to add to balance",
|
||||||
|
value: 1000.00,
|
||||||
|
type: 10,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/QuarksBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} message
|
||||||
|
* @param {string[]} args
|
||||||
|
* @param {*} param3
|
||||||
|
*/
|
||||||
|
run: async (client, interaction, args, { GuildDB }) => {
|
||||||
|
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
|
||||||
|
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send money from wallet
|
||||||
|
|
||||||
|
let targetUserID = args[0].value.replace('<@!', '').replace('>', '');
|
||||||
|
let banking = await client.dbo.collection("banking").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||||
|
|
||||||
|
if (!banking) {
|
||||||
|
banking = {
|
||||||
|
account: {
|
||||||
|
userID: targetUserID,
|
||||||
|
balance: GuildDB.startingBalance + args[1].value,
|
||||||
|
cash: 0.00,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client.dbo.collection("banking").insertOne(banking, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setTitle(err)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let newBalance = banking.account.balance + args[1].value;
|
||||||
|
|
||||||
|
client.dbo.collection("banking").updateOne({"account.userID":targetUserID},{$set:{"account.balance":newBalance}}, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setTitle(err)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let successEmbed = new MessageEmbed()
|
||||||
|
.setTitle('Success')
|
||||||
|
.setDescription(`Successfully added $${args[1].value.toFixed(2)} to <@${targetUserID}>'s balance`)
|
||||||
|
.setColor('GREEN');
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
+1
-1
@@ -13,7 +13,7 @@ module.exports = {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: "user",
|
name: "user",
|
||||||
description: "user to give item",
|
description: "user to give money",
|
||||||
value: "user",
|
value: "user",
|
||||||
type: 6,
|
type: 6,
|
||||||
required: true,
|
required: true,
|
||||||
|
|||||||
Reference in new issue
Block a user