debug button/menu interactions
This commit is contained in:
12 files changed
+844
-834
No files matched your search
+129
-68
@@ -113,7 +113,7 @@ module.exports = {
|
||||
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||
}
|
||||
|
||||
let banking = await client.dbo.collection("banks").findOne({"account.userID": interaction.member.user.id}).then(banking => banking);
|
||||
let banking = await client.dbo.collection("banks").findOne({"banking.userID": interaction.member.user.id}).then(banking => banking);
|
||||
|
||||
if (!banking) {
|
||||
banking = {
|
||||
@@ -160,6 +160,26 @@ module.exports = {
|
||||
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
|
||||
|
||||
if (!inventory) {
|
||||
inventory = {
|
||||
userID: interaction.member.user.id,
|
||||
guilds: {
|
||||
[GuildDB.serverID]: {
|
||||
items: [{
|
||||
name: 'Wallet',
|
||||
type: 'wallet',
|
||||
description: '`/inventory wallet` to view wallet',
|
||||
cash: 0.00,
|
||||
ID: {
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
dob: '',
|
||||
addr: '',
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register inventory for user
|
||||
let newInventory = new Inventory();
|
||||
newInventory.createInventory(interaction.member.user.id, GuildDB.serverID);
|
||||
@@ -174,7 +194,7 @@ module.exports = {
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
}
|
||||
} else inventory = inventory.inventory;
|
||||
|
||||
if (!client.exists(inventory.guilds[GuildDB.serverID])) {
|
||||
const success = addInventory(inventory.guilds, GuildDB.serverID, interaction.member.user.id, client);
|
||||
@@ -197,10 +217,10 @@ module.exports = {
|
||||
return interaction.send({ embeds: [nsf] });
|
||||
}
|
||||
|
||||
newBalance = banking.guilds[GuildDB.serverID].account.balance + args[0].options[0].value;
|
||||
newCash = Math.abs(banking.guilds[GuildDB.serverID].account.cash.toFixed(2) - args[0].options[0].value);
|
||||
const newBalance = banking.guilds[GuildDB.serverID].account.balance + args[0].options[0].value;
|
||||
const newCash = Math.abs(banking.guilds[GuildDB.serverID].account.cash.toFixed(2) - args[0].options[0].value);
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
@@ -238,10 +258,10 @@ module.exports = {
|
||||
return interaction.send({ embeds: [nsf] });
|
||||
}
|
||||
|
||||
newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[0].value;
|
||||
newCash = banking.guilds[GuildDB.serverID].account.cash + args[0].options[0].value;
|
||||
const newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[0].value;
|
||||
const newCash = banking.guilds[GuildDB.serverID].account.cash + args[0].options[0].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
@@ -278,11 +298,11 @@ module.exports = {
|
||||
// Show target users balance
|
||||
|
||||
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!targetUserBanking) {
|
||||
banking = {
|
||||
userID: interaction.member.user.id,
|
||||
targetUserBanking = {
|
||||
userID: targetUserID,
|
||||
guidls: {
|
||||
[guildID]: {
|
||||
account: {
|
||||
@@ -308,7 +328,7 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
|
||||
} else banking = banking.banking;
|
||||
} else targetUserBanking = targetUserBanking.banking;
|
||||
|
||||
if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) {
|
||||
const success = addBank(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
||||
@@ -327,8 +347,8 @@ module.exports = {
|
||||
|
||||
balanceEmbed.setTitle(`${User.tag}'s Bank Records`);
|
||||
balanceEmbed.addFields(
|
||||
{ name: '**Bank**', value: `$${targetUserBanking.account.balance}`, inline: true },
|
||||
{ name: '**Cash**', value: `$${targetUserBanking.account.cash}`, inline: true });
|
||||
{ name: '**Bank**', value: `$${targetUserBanking.guilds[GuildDB.serverID].account.balance}`, inline: true },
|
||||
{ name: '**Cash**', value: `$${targetUserBanking.guilds[GuildDB.serverID].account.cash}`, inline: true });
|
||||
|
||||
} else {
|
||||
// Show command authors balance
|
||||
@@ -353,9 +373,9 @@ module.exports = {
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
|
||||
newCash = banking.guilds[GuildDB.serverID].account.cash - args[0].options[1].value;
|
||||
const newCash = banking.guilds[GuildDB.serverID].account.cash - args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
@@ -378,10 +398,30 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
|
||||
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
let targetUserInventory = await client.dbo.collection("inventories").findOne({"inventory.userID":targetUserID}).then(inventory => inventory);
|
||||
|
||||
if (!targetUserInventory) {
|
||||
targetUserBanking = {
|
||||
userID: targetUserID,
|
||||
guilds: {
|
||||
[GuildDB.serverID]: {
|
||||
items: [{
|
||||
name: 'Wallet',
|
||||
type: 'wallet',
|
||||
description: '`/inventory wallet` to view wallet',
|
||||
cash: 0.00,
|
||||
ID: {
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
dob: '',
|
||||
addr: '',
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register inventory for user
|
||||
let newInventory = new Inventory();
|
||||
newInventory.createInventory(targetUserID, GuildDB.serverID);
|
||||
@@ -397,7 +437,7 @@ module.exports = {
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
}
|
||||
} else targetUserInventory = targetUserInventory.inventory;
|
||||
|
||||
if (!client.exists(targetUserInventory.guilds[GuildDB.serverID])) {
|
||||
const success = addInventory(targetUserInventory.guilds, GuildDB.serverID, targetUserID, client);
|
||||
@@ -411,7 +451,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
let newTargetCash = targetUserInventory.inventory.guilds[GuildDB.serverID].items[0].cash + args[0].options[1].value;
|
||||
const newTargetCash = targetUserInventory.inventory.guilds[GuildDB.serverID].items[0].cash + args[0].options[1].value;
|
||||
client.dbo.collection("inventories").updateOne({"inventory.userID":targetUserID, [`inventory.guilds.${GuildDB.serverID}.items.type`]:"wallet"},
|
||||
{$set:{[`inventory.guilds.${GuildDB.serverID}.items.$.cash`]:newTargetCash}}, function(err, res) {
|
||||
if (err) {
|
||||
@@ -424,42 +464,59 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!targetUserBanking) {
|
||||
targetUserBanking = {
|
||||
account: {
|
||||
userID: targetUserID,
|
||||
balance: GuildDB.startingBalance,
|
||||
cash: args[0].options[1].value,
|
||||
userID: targetUserID,
|
||||
guidls: {
|
||||
[GuildDB.serverID]: {
|
||||
account: {
|
||||
balance: GuildDB.startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banks").insertOne(targetUserBanking, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let newTargetCash = targetUserBanking.account.cash + args[0].options[1].value;
|
||||
// Register inventory for user
|
||||
let newBank = new Bank();
|
||||
newBank.createBank(targetUserID, GuildDB.serverID, GuildDB.startingBalance);
|
||||
newBank.save()
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
} else targetUserBanking = targetUserBanking.banking;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID": targetUserID}, {$set: {[`banking.guilds.${GuildDB.serverID}.account.cash`]: newTargetCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) {
|
||||
const success = addBank(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
||||
if (!success) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banks").updateOne({"banking.userID": targetUserID}, {$set: {[`banking.guilds.${GuildDB.serverID}.account.cash`]: newTargetCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setTitle('Success')
|
||||
@@ -479,9 +536,9 @@ module.exports = {
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
|
||||
newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value;
|
||||
const newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
@@ -492,15 +549,19 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
|
||||
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!targetUserBanking) {
|
||||
targetUserBanking = {
|
||||
account: {
|
||||
userID: targetUserID,
|
||||
balance: (GuildDB.startingBalance + args[0].options[1].value),
|
||||
cash: 0.00,
|
||||
userID: targetUserID,
|
||||
guilds: {
|
||||
[GuildDB.serverID]: {
|
||||
account: {
|
||||
balance: (GuildDB.startingBalance + args[0].options[1].value),
|
||||
cash: 0.00,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,20 +575,20 @@ module.exports = {
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let newTargetBalance = targetUserBanking.account.balance + args[0].options[1].value;
|
||||
} else targetUserBanking = targetUserBanking.banking;
|
||||
|
||||
const newTargetBalance = targetUserBanking.guilds[GuildDB.serverID].account.balance + args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
}
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.error(err);
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setTitle('Bank Notice:')
|
||||
|
||||
Reference in new issue
Block a user