12.8.3 fix internal error handling
This commit is contained in:
12 files changed
+211
-74
No files matched your search
@@ -181,13 +181,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');
|
||||
}
|
||||
|
||||
if (args[0].name == 'view') {
|
||||
@@ -251,7 +251,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) return client.sendInternalError(err);
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
|
||||
let message = new EmbedBuilder()
|
||||
@@ -271,7 +271,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) return client.sendInternalError(err);
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
|
||||
let message = new EmbedBuilder()
|
||||
@@ -454,7 +454,7 @@ module.exports = {
|
||||
let item = inventory.guilds[GuildDB.serverID].items[args[0].options[0].value-1];
|
||||
|
||||
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
|
||||
if (err) return client.sendInternalError(err);
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
|
||||
let message = new EmbedBuilder()
|
||||
.setTitle(`You ${dropActions[Math.floor(Math.random() * dropActions.length)]} your ${item.name}`)
|
||||
@@ -487,7 +487,7 @@ module.exports = {
|
||||
newInventory.createInventory(targetUserID, GuildDB.serverID);
|
||||
newInventory.addItem(item);
|
||||
newInventory.save().catch(err => {
|
||||
if (err) return client.sendInternalError(err);
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
} else {
|
||||
targetUserInventory = targetUserIventory.inventory;
|
||||
@@ -504,10 +504,10 @@ module.exports = {
|
||||
}
|
||||
|
||||
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
|
||||
if (err) return client.sendInternalError(err);
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
client.dbo.collection('inventories').updateOne({'inventory.userID': targetUserID}, {$push: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
|
||||
if (err) return client.sendInternalError(err);
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ module.exports = {
|
||||
action = 'cleared';
|
||||
const tempWallet = inventory.guilds[GuildDB.serverID].items[0];
|
||||
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id},{$set:{[`inventory.guilds.${GuildDB.serverID}.items`]: [tempWallet]}},function(err, res) {
|
||||
if (err) return client.sendInternalError(err);
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
} else if (queryString==`inventoryClear-no-${interaction.member.user.id}`) action = 'kept';
|
||||
|
||||
|
||||
Reference in new issue
Block a user