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

+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()