Merge pull request #158 from mariusbegby/handle-deferred-sent-interaction-on-permission-validator

Update permissionValidator.js
This commit is contained in:
Marius Begby authored and GitHub committed 2023-08-18 12:27:56 +02:00
commit 3658c94a95
1 file changed
+7
@@ -36,7 +36,9 @@ exports.cannotSendMessageInChannel = async (interaction) => {
try { try {
// we can still send ephemeral replies in channels we can't view, so sending message to user instead // we can still send ephemeral replies in channels we can't view, so sending message to user instead
if (!interaction.deferred && !interaction.replied) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
}
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [
new EmbedBuilder() new EmbedBuilder()
@@ -48,11 +50,16 @@ exports.cannotSendMessageInChannel = async (interaction) => {
ephemeral: true ephemeral: true
}); });
} catch (error) { } catch (error) {
if(error.message == "The reply to this interaction has already been sent or deferred.") {
logger.warn('Error while sending ephemereal message about insufficient permissions to send message in channel.');
logger.debug(error);
} else {
logger.error( logger.error(
error, error,
'Failed to send ephemeral reply to user in channel that bot cannot view/send message in.' 'Failed to send ephemeral reply to user in channel that bot cannot view/send message in.'
); );
} }
}
return true; return true;
} }