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

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