From c6ba35796fb4083353bf6a67b34c8784c36649eb Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Fri, 5 Aug 2022 15:34:01 -0700 Subject: [PATCH] better error handling --- commands/311.js | 8 ++++++-- commands/911.js | 6 +++++- commands/me.js | 6 +++++- commands/tweet.js | 6 +++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/commands/311.js b/commands/311.js index 0a3d09d..f541408 100644 --- a/commands/311.js +++ b/commands/311.js @@ -146,7 +146,7 @@ module.exports = { .setStyle("DANGER"), ) - return ButtonInteraction.update({ embeds: [embed911], components: [opt] }); + return ButtonInteraction.update({ embeds: [embed311], components: [opt] }); }) const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.dispatchChannel); @@ -157,7 +157,11 @@ module.exports = { return interaction.send({ embeds: [embed] }); } - channel.send({ content: `<@&${GuildDB.dispatcherRole}> New 311 report`, embeds: [embed911], components: [opt] }); + try { + channel.send({ content: `<@&${GuildDB.dispatcherRole}> New 311 report`, embeds: [embed311], components: [opt] }); + } catch (err) { + return interaction.send(`<@${client.user.id}> Does not have permissions to send to the channel.\nMake sure your admins give <@${client.user.id}> access to all channels required. `) + } return interaction.send('A report has been sent via 311.'); }, }, diff --git a/commands/911.js b/commands/911.js index f42c257..d4333a8 100644 --- a/commands/911.js +++ b/commands/911.js @@ -157,7 +157,11 @@ module.exports = { return interaction.send({ embeds: [embed] }); } - channel.send({ content: `<@&${GuildDB.dispatcherRole}> New 911 call!`, embeds: [embed911], components: [opt] }); + try { + channel.send({ content: `<@&${GuildDB.dispatcherRole}> New 911 call!`, embeds: [embed911], components: [opt] }); + } catch (err) { + return interaction.send(`<@${client.user.id}> Does not have permissions to send to the channel.\nMake sure your admins give <@${client.user.id}> access to all channels required. `) + } return interaction.send('911 Alerted!'); }, }, diff --git a/commands/me.js b/commands/me.js index 1f1b8d2..d0eb366 100644 --- a/commands/me.js +++ b/commands/me.js @@ -46,7 +46,11 @@ module.exports = { return interaction.send({ embeds: [embed] }); } - channel.send({ embeds: [actionEmbed] }); + try { + channel.send({ embeds: [actionEmbed] }); + } catch (err) { + return interaction.send(`<@${client.user.id}> Does not have permissions to send to the channel.\nMake sure your admins give <@${client.user.id}> access to all channels required. `) + } return interaction.send('Action performed'); } else { return interaction.send({ content: 'Action performed', embeds: [actionEmbed] }); diff --git a/commands/tweet.js b/commands/tweet.js index 79f989d..2cde3ea 100644 --- a/commands/tweet.js +++ b/commands/tweet.js @@ -51,7 +51,11 @@ module.exports = { return interaction.send({ embeds: [embed] }); } - channel.send({ embeds: [tweetEmbed] }); + try { + channel.send({ embeds: [tweetEmbed] }); + } catch (err) { + return interaction.send(`<@${client.user.id}> Does not have permissions to send to the channel.\nMake sure your admins give <@${client.user.id}> access to all channels required. `) + } return interaction.send('Tweeted!'); } else { return interaction.send({ content: 'Tweeted!', embeds: [tweetEmbed] });