12.8.2 debug money command
This commit is contained in:
2 files changed
+34
-12
No files matched your search
+33
-11
@@ -1,5 +1,6 @@
|
|||||||
const { EmbedBuilder } = require('discord.js');
|
const { EmbedBuilder } = require('discord.js');
|
||||||
const { Bank, addBank } = require('../structures/bank');
|
const { Bank, addBank } = require('../structures/bank');
|
||||||
|
const bitfieldCalculator = require('discord-bitfield-calculator');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "money",
|
name: "money",
|
||||||
@@ -13,15 +14,34 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: "add_or_remove",
|
name: "add",
|
||||||
description: "Add or remove money from a user",
|
description: "Add money to user",
|
||||||
value: "add_or_remove",
|
value: "add",
|
||||||
type: 3,
|
type: 1,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "amount",
|
||||||
|
description: "The amount to add to balance",
|
||||||
|
value: "amount",
|
||||||
|
type: 10,
|
||||||
|
min_value: 0.01,
|
||||||
required: true,
|
required: true,
|
||||||
choices: [
|
},
|
||||||
{ name: "add", value: "add" }, { name: "remove", value: "remove" },
|
{
|
||||||
|
name: "to",
|
||||||
|
description: "User to alter balance",
|
||||||
|
value: "to",
|
||||||
|
type: 6,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "remove",
|
||||||
|
description: "Remove or remove money from a user",
|
||||||
|
value: "remove",
|
||||||
|
type: 1,
|
||||||
|
options: [
|
||||||
{
|
{
|
||||||
name: "amount",
|
name: "amount",
|
||||||
description: "The amount to add to balance",
|
description: "The amount to add to balance",
|
||||||
@@ -37,6 +57,8 @@ module.exports = {
|
|||||||
type: 6,
|
type: 6,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
],
|
],
|
||||||
SlashCommand: {
|
SlashCommand: {
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +76,7 @@ module.exports = {
|
|||||||
if (client.exists(GuildDB.botAdmin) && interaction.member.roles.includes(GuildDB.botAdmin)) canUseCommand = true;
|
if (client.exists(GuildDB.botAdmin) && interaction.member.roles.includes(GuildDB.botAdmin)) canUseCommand = true;
|
||||||
if (!canUseCommand) return interaction.send({ content: 'You don\'t have the permissions to use this command.' });
|
if (!canUseCommand) return interaction.send({ content: 'You don\'t have the permissions to use this command.' });
|
||||||
|
|
||||||
const targetUserID = args[2].value.replace('<@!', '').replace('>', '');
|
const targetUserID = args[0].options[1].value.replace('<@!', '').replace('>', '');
|
||||||
let banking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
let banking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
||||||
|
|
||||||
if (!banking) {
|
if (!banking) {
|
||||||
@@ -84,16 +106,16 @@ module.exports = {
|
|||||||
if (!success) return client.sendInternalError('Failed to add bank');
|
if (!success) return client.sendInternalError('Failed to add bank');
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBalance = args[0] == 'add'
|
const newBalance = args[0].name == 'add'
|
||||||
? banking.guilds[GuildDB.serverID].account.balance + args[1].value
|
? banking.guilds[GuildDB.serverID].account.balance + args[0].options[1].value
|
||||||
: banking.guilds[GuildDB.serverID].account.balance - args[1].value;
|
: banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value;
|
||||||
|
|
||||||
client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||||
if (err) return client.sendInternalError(err);
|
if (err) return client.sendInternalError(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
const successEmbed = new EmbedBuilder()
|
const successEmbed = new EmbedBuilder()
|
||||||
.setDescription(`Successfully ${args[0] == 'add' ? 'added' : 'removed'} $${args[0].options[1].value.toFixed(2)} ${args[0] == 'add' ? 'to' : 'from'} <@${targetUserID}>'s balance`)
|
.setDescription(`Successfully ${args[0] == 'add' ? 'added' : 'removed'} $${args[0].options[0].value.toFixed(2)} ${args[0] == 'add' ? 'to' : 'from'} <@${targetUserID}>'s balance`)
|
||||||
.setColor(client.config.Colors.Green);
|
.setColor(client.config.Colors.Green);
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ require('dotenv').config();
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Dev: "PROD.",
|
Dev: "PROD.",
|
||||||
Version: "12.8.1", // (major).(feature).(revision/bug/refactoring)
|
Version: "12.8.2", // (major).(feature).(revision/bug/refactoring)
|
||||||
Admins: ["362791661274660874", "329371697570381824"], // Admins of the bot
|
Admins: ["362791661274660874", "329371697570381824"], // Admins of the bot
|
||||||
DefaultPrefix: "?",
|
DefaultPrefix: "?",
|
||||||
ServerID: "955668596745461830",
|
ServerID: "955668596745461830",
|
||||||
|
|||||||
Reference in new issue
Block a user