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

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