12.8.3 fix internal error handling

This commit is contained in:
SowinskiBraeden committed 2022-10-16 13:07:32 -07:00
1 parent 060ef78db4
commit dad2cddf61
12 files changed
+211 -74

No files matched your search

+6 -6
View File
@@ -50,13 +50,13 @@ module.exports = {
let newInventory = new Inventory();
newInventory.createInventory(interaction.member.user.id, GuildDB.serverID);
newInventory.save().catch(err => {
if (err) return client.sendInternalError(err);
if (err) return client.sendInternalError(interaction, 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) return client.sendInternalError('Failed to add inventory');
if (!success) return client.sendInternalError(interaction, 'Failed to add inventory');
}
const now = new Date();
@@ -92,14 +92,14 @@ module.exports = {
let newBank = new Bank();
newBank.createBank(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance);
newBank.save().catch(err => {
if (err) return client.sendInternalError(err);
if (err) return client.sendInternalError(interaction, 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) return client.sendInternalError('Failed to add bank');
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
}
let job, earned;
@@ -112,11 +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) return client.sendInternalError(err);
if (err) return client.sendInternalError(interaction, err);
});
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id}, {$set: {[`inventory.guilds.${GuildDB.serverID}.lastWork`]: now}}, function(err, res) {
if (err) return client.sendInternalError(err);
if (err) return client.sendInternalError(interaction, err);
});
const success = new EmbedBuilder()