v12.7.8 clean internal error handling

This commit is contained in:
SowinskiBraeden committed 2022-10-12 17:30:27 -07:00
1 parent e4a3000a15
commit ded3831fb1
11 files changed
+154 -510

No files matched your search

+71 -191
View File
@@ -132,30 +132,15 @@ module.exports = {
// Register inventory for user
let newBank = new Bank();
newBank.createBank(interaction.member.user.id, 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] });
}
});
newBank.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else banking = banking.banking;
if (!client.exists(banking.guilds[GuildDB.serverID])) {
const success = addBank(banking.guilds, GuildDB.serverID, interaction.member.user.id, 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] });
}
if (!success) return client.sendInternalError('Failed to add bank');
}
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
@@ -184,29 +169,14 @@ module.exports = {
// Register inventory for user
let newInventory = new Inventory();
newInventory.createInventory(interaction.member.user.id, GuildDB.serverID);
newInventory.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] });
}
});
newInventory.save().catch(err => {
if (err) return client.sendInternalError(err)
});
} else inventory = inventory.inventory;
if (!client.exists(inventory.guilds[GuildDB.serverID])) {
const success = addInventory(inventory.guilds, GuildDB.serverID, interaction.member.user.id, client);
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] });
}
if (!success) return client.sendInternalError('Failed to add inventory');
}
if (args[0].name == 'deposit') {
@@ -222,25 +192,19 @@ module.exports = {
const newCash = Math.abs(banking.guilds[GuildDB.serverID].account.cash.toFixed(2) - args[0].options[0].value);
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()
.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 (err) return client.sendInternalError(err);
});
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id, [`inventory.guilds.${GuildDB.serverID}.items.type`]:"wallet"},
{$set:{[`inventory.guilds.${GuildDB.serverID}.items.$.cash`]:newCash}}, 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("inventories").updateOne(
{
"inventory.userID": interaction.member.user.id,
[`inventory.guilds.${GuildDB.serverID}.items.type`]: "wallet"
},
{
$set: {
[`inventory.guilds.${GuildDB.serverID}.items.$.cash`]: newCash
}
}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
@@ -263,25 +227,19 @@ module.exports = {
const newCash = banking.guilds[GuildDB.serverID].account.cash + args[0].options[0].value;
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()
.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 (err) return client.sendInternalError(err);
});
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id, [`inventory.guilds.${GuildDB.serverID}.items.type`]:"wallet"},
{$set:{[`inventory.guilds.${GuildDB.serverID}.items.$.cash`]:newCash}}, 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("inventories").updateOne(
{
"inventory.userID": interaction.member.user.id,
[`inventory.guilds.${GuildDB.serverID}.items.type`]: "wallet"
},
{
$set: {
[`inventory.guilds.${GuildDB.serverID}.items.$.cash`]: newCash
}
}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
@@ -317,30 +275,15 @@ module.exports = {
// 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] });
}
});
newBank.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else targetUserBanking = targetUserBanking.banking;
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] });
}
if (!success) return client.sendInternalError('Failed to add bank');
}
// This lame line of code to get username without ping on discord
@@ -377,26 +320,20 @@ module.exports = {
const newCash = banking.guilds[GuildDB.serverID].account.cash - args[0].options[1].value;
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()
.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 (err) return client.sendInternalError(err);
});
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id, [`inventory.guilds.${GuildDB.serverID}.items.type`]:"wallet"},
{$set:{[`inventory.guilds.${GuildDB.serverID}.items.$.cash`]:newCash}}, 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("inventories").updateOne(
{
"inventory.userID": interaction.member.user.id,
[`inventory.guilds.${GuildDB.serverID}.items.type`]: "wallet"
},
{
$set: {
[`inventory.guilds.${GuildDB.serverID}.items.$.cash`] :newCash
}
}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
@@ -427,42 +364,28 @@ module.exports = {
let newInventory = new Inventory();
newInventory.createInventory(targetUserID, GuildDB.serverID);
newInventory.inventory.guilds[GuildDB.serverID].items[0].cash = args[0].options[1].value;
newInventory.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] });
}
});
newInventory.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else targetUserInventory = targetUserInventory.inventory;
if (!client.exists(targetUserInventory.guilds[GuildDB.serverID])) {
const success = addInventory(targetUserInventory.guilds, GuildDB.serverID, targetUserID, client);
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] });
}
if (!success) return client.sendInternalError('Failed to add inventory');
}
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) {
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("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) return client.sendInternalError(err);
});
let targetUserBanking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
@@ -483,40 +406,18 @@ module.exports = {
// 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] });
}
});
newBank.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else targetUserBanking = targetUserBanking.banking;
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] });
}
if (!success) return client.sendInternalError('Failed to add bank');
}
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] });
}
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
@@ -540,14 +441,7 @@ module.exports = {
const newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value;
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()
.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 (err) return client.sendInternalError(err);
});
const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
@@ -567,28 +461,14 @@ module.exports = {
}
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] });
}
if (err) return client.sendInternalError(err);
});
} else targetUserBanking = targetUserBanking.banking;
const newTargetBalance = targetUserBanking.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`]: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] });
}
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
+5 -27
View File
@@ -76,43 +76,21 @@ module.exports = {
// 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] });
}
});
newBank.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else banking = banking.banking;
if (!client.exists(banking.guilds[GuildDB.serverID])) {
const success = addBank(banking.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] });
}
if (!success) return client.sendInternalError('Failed to add bank');
}
const newTargetBalance = 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`]: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] });
}
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
+1 -1
View File
@@ -87,7 +87,7 @@ module.exports = {
(x) => x.aliases && x.aliases.includes(args[0].options[0].value)
);
if (!cmd)
return client.sendTime(
return client.sendError(
interaction,
`❌ | Unable to find that command.`
);
+6 -35
View File
@@ -179,29 +179,14 @@ module.exports = {
// Register inventory for user
let newInventory = new Inventory();
newInventory.createInventory(interaction.member.user.id, GuildDB.serverID);
newInventory.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] });
}
});
newInventory.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else inventory = inventory.inventory
if (!client.exists(inventory.guilds[GuildDB.serverID])) {
const success = addInventory(inventory.guilds, GuildDB.serverID, interaction.member.user.id, client);
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] });
}
if (!success) return client.sendInternalError('Failed to add inventory');
}
if (args[0].name == 'view') {
@@ -265,14 +250,7 @@ module.exports = {
}
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$push: {[`inventory.guilds.${GuildDB.serverID}.items`]: firearm}}, 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 (err) return client.sendInternalError(err);
});
let message = new EmbedBuilder()
@@ -292,14 +270,7 @@ module.exports = {
}
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$push: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, 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 (err) return client.sendInternalError(err);
});
let message = new EmbedBuilder()
+5 -27
View File
@@ -73,30 +73,15 @@ module.exports = {
// 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] });
}
});
newBank.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else banking = banking.banking;
if (!client.exists(banking.guilds[GuildDB.serverID])) {
const success = addBank(banking.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] });
}
if (!success) return client.sendInternalError('Failed to add bank');
}
const newBalance = args[0] == 'add'
@@ -104,14 +89,7 @@ module.exports = {
: banking.guilds[GuildDB.serverID].account.balance - args[1].value;
client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, 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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
+8 -23
View File
@@ -70,37 +70,22 @@ module.exports = {
// Register inventory for user with item givn
let newInventory = new Inventory();
newInventory.createInventory(targetUserID, GuildDB.serverID);
newInventory.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] });
}
});
newInventory.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else inventory = targetUserInventory.inventory;
if (!client.exists(inventory.guilds[GuildDB.serverID])) {
const success = addInventory(inventory.guilds, GuildDB.serverID, targetUserID, client);
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] });
}
if (!success) return client.sendInternalError('Failed to add inventory');
}
// Display Inventory
if (args[1]) {
if (args[1].value < 0 || args[1].value > inventory.guilds[GuildDB.serverID].items.length) {
let embed = new EmbedBuilder()
.setTitle("Please provide a valid item number")
.setColor(client.config.Colors.Red)
.setTitle("Please provide a valid item number")
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
@@ -138,8 +123,8 @@ module.exports = {
}
let inventoryEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle(`${User.tag.split('#')[0]}'s Inventory`);
.setColor(client.config.Colors.Default)
.setTitle(`${User.tag.split('#')[0]}'s Inventory`);
let description = "```";
for (let i = 0; i < inventory.guilds[GuildDB.serverID].items.length; i++) {
+32 -123
View File
@@ -395,14 +395,7 @@ module.exports = {
if (error) return interaction.send({ embeds: [errorEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push:{"server.allowedChannels": channelid}}, 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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
@@ -449,19 +442,12 @@ module.exports = {
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.actionChannel":channelid}},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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> as the action channel.`);
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> as the action channel.`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
@@ -495,19 +481,12 @@ module.exports = {
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.tweetChannel":channelid}},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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> as the tweet channel.`);
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> as the tweet channel.`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
@@ -541,19 +520,12 @@ module.exports = {
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.advertsChannel":channelid}},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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> for advertisements.`)
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> for advertisements.`)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
@@ -588,19 +560,12 @@ module.exports = {
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.dispatchChannel":channelid}},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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> for dispatchers.`)
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> for dispatchers.`)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
@@ -625,19 +590,12 @@ module.exports = {
} else if (args[0].name == 'starting_balance') {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {"server.startingBalance":args[0].options[0].value}, 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 (err) return client.sendInternalError(err);
});
let successEmbed = new EmbedBuilder()
.setColor('GREEN')
.setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as starting balance`);
.setColor('GREEN')
.setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as starting balance`);
return interaction.send({ embeds: [successEmbed] });
@@ -661,26 +619,19 @@ module.exports = {
}
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, 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 (err) return client.sendInternalError(err);
});
} else {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID, "server.incomeRoles.role": roleId},
{$set: {"server.incomeRoles.$.income": args[0].options[0].options[1].value}}, 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("guilds").updateOne({
"server.serverID": GuildDB.serverID,
"server.incomeRoles.role": roleId
},
{
$set: {
"server.incomeRoles.$.income": args[0].options[0].options[1].value
}
}, function(err, res) {
if (err) return client.sendInternalError(err);
});
}
const perform = searchIndex = -1 ? 'set' : 'updated';
@@ -725,14 +676,7 @@ module.exports = {
const roleId = args[0].options[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.commercialRole": roleId}}, 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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
@@ -767,14 +711,7 @@ module.exports = {
if (args[0].options[0].name== 'set') {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.officerRole": roleId}}, 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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
@@ -809,14 +746,7 @@ module.exports = {
const roleId = args[0].options[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.dispatcherRole": roleId}}, 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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
@@ -852,14 +782,7 @@ module.exports = {
const roleId = args[0].options[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.botAdmin": roleId}}, 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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
@@ -891,14 +814,7 @@ module.exports = {
} else if (args[0].name == 'only_officers_search') {
const setting = args[0].options[0];
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.onlyOfficersSearch": setting}}, 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 (err) return client.sendInternalError(err);
});
const title = setting ? 'True: Only officers can use /search' : 'False: Any user can use /search';
@@ -910,14 +826,7 @@ module.exports = {
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'casino_multiplier') {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.casinoMultiplier": args[0].options[0]}}, 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 (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
+5 -27
View File
@@ -82,29 +82,14 @@ module.exports = {
// Register inventory for user
let newInventory = new Inventory();
newInventory.createInventory(interaction.member.user.id, GuildDB.serverID);
newInventory.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] });
}
});
newInventory.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else inventory = inventory.inventory
if (!client.exists(inventory.guilds[GuildDB.serverID])) {
const success = addInventory(inventory.guilds, GuildDB.serverID, interaction.member.user.id, client);
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] });
}
if (!success) return client.sendInternalError('Failed to add inventory');
}
if (args[0].name == "view") {
@@ -155,14 +140,7 @@ module.exports = {
}
client.dbo.collection("inventories").updateOne(query, update, 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 (err) return client.sendInternalError(err);
});
let successEmbed = new EmbedBuilder()
+10 -54
View File
@@ -49,29 +49,14 @@ module.exports = {
// Register inventory for user
let newInventory = new Inventory();
newInventory.createInventory(interaction.member.user.id, GuildDB.serverID);
newInventory.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] });
}
});
newInventory.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else inventory = inventory.inventory
if (!client.exists(inventory.guilds[GuildDB.serverID])) {
const success = addInventory(inventory.guilds, GuildDB.serverID, interaction.member.user.id, client);
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] });
}
if (!success) return client.sendInternalError('Failed to add inventory');
}
const now = new Date();
@@ -106,30 +91,15 @@ module.exports = {
// Register inventory for user
let newBank = new Bank();
newBank.createBank(interaction.member.user.id, 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] });
}
});
newBank.save().catch(err => {
if (err) return client.sendInternalError(err);
});
} else banking = banking.banking;
if (!client.exists(banking.guilds[GuildDB.serverID])) {
const success = addBank(banking.guilds, GuildDB.serverID, interaction.member.user.id, 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] });
}
if (!success) return client.sendInternalError('Failed to add bank');
}
let job, earned;
@@ -142,25 +112,11 @@ module.exports = {
newBalance = banking.guilds[GuildDB.serverID].account.balance + earned
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()
.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 (err) return client.sendInternalError(err);
});
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id}, {$set: {[`inventory.guilds.${GuildDB.serverID}.lastWork`]: now}}, 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 (err) return client.sendInternalError(err);
});
const success = new EmbedBuilder()
+1 -1
View File
@@ -2,7 +2,7 @@ require('dotenv').config();
module.exports = {
Dev: "PROD.",
Version: "12.7.7",
Version: "12.7.8",
Admins: ["362791661274660874", "329371697570381824"], // Admins of the bot
DefaultPrefix: "?",
ServerID: "955668596745461830",
+10 -1
View File
@@ -131,7 +131,7 @@ class QuarksBot extends Client {
});
}
sendTime(Channel, Error) {
sendError(Channel, Error) {
let embed = new EmbedBuilder()
.setColor(this.config.Red)
.setDescription(Error);
@@ -139,6 +139,15 @@ class QuarksBot extends Client {
Channel.send(embed);
}
sendInternalError(Interaction, Error) {
this.error(Error);
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)
Interaction.send({ embeds: [embed] });
}
// Calls register for guild and global commands
RegisterSlashCommands() {
RegisterGlobalCommands(this);