diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 109e89b..041b28a 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -19,8 +19,8 @@ module.exports = async (client, interaction) => { content: "This button is not for you", flags: (1 << 6) }) - } - const successEmbed = new EmbedBuilder() + } + const successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setTitle(`Successfully Deleted 311 Report.`) @@ -130,14 +130,7 @@ module.exports = async (client, interaction) => { 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) { - 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); let message = new EmbedBuilder() .setTitle(`You ${dropActions[Math.floor(Math.random() * dropActions.length)]} your ${item.name}`) @@ -168,17 +161,9 @@ module.exports = async (client, interaction) => { let newInventory = new Inventory(); newInventory.createInventory(targetUserID, GuildDB.serverID); newInventory.addItem(item); - 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.update({ embeds: [embed], components: [] }); - } - }); + newInventory.save().catch(err => { + if (err) return client.sendInternalError(err); + }); } else { targetUserInventory = targetUserIventory.inventory; if (!client.exists(targetUserInventory.guilds[GuildDB.serverID])) { @@ -194,24 +179,10 @@ module.exports = async (client, interaction) => { } client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); client.dbo.collection('inventories').updateOne({'inventory.userID': targetUserID}, {$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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } @@ -237,14 +208,7 @@ module.exports = async (client, interaction) => { 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) { - 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (queryString==`inventoryClear-no-${interaction.member.user.id}`) action = 'kept'; @@ -330,14 +294,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -360,14 +317,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.actionChannel": null}},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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (queryString==`no-${interaction.member.user.id}`) action = 'kept'; @@ -390,14 +340,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.tweetChannel": null}},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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -420,14 +363,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.advertsChannel": null}},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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -450,14 +386,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.dispatchChannel": null}},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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -480,14 +409,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": roleId}}, 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -510,14 +432,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.commercialRole": null}}, 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -540,14 +455,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='no') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.officerRole": null}}, 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -570,14 +478,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.dispatcherRole": null}}, 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -600,14 +501,7 @@ module.exports = async (client, interaction) => { if (interaction.customId.split('-')[1]=='yes') { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.botAdmin": null}}, 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; @@ -645,14 +539,7 @@ module.exports = async (client, interaction) => { onlyOfficersSearch: false, } client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server": defaultGuildConfig}}, 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.update({ embeds: [embed], components: [] }); - } + if (err) return client.sendInternalError(err); }); } else if (interaction.customId.split('-')[1]=='no') action = 'kept';