fix: Added check on text channel permissions on intereactionCreate

This commit is contained in:
Marius Begby committed 2023-07-23 11:48:43 +02:00
1 parent b68b7dac95
commit 0c7a627e83
2 files changed
+36 -2

No files matched your search

+31 -2
View File
@@ -10,13 +10,42 @@ exports.cannotJoinVoiceOrTalk = async (interaction) => {
embeds: [
new EmbedBuilder()
.setDescription(
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to play audio in the voice channel you are in.\n\nPlease make sure I have the **Connect** and **Speak** permissions in this voice channel.`
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to play audio in the voice channel you are in.\n\nPlease make sure I have the **\`Connect\`** and **\`Speak\`** permissions in this voice channel.`
)
.setColor(embedOptions.colors.warning)
]
});
logger.debug(`User tried to use command ${interaction.commandName} but was not in a voice channel.`);
logger.debug(
`User tried to use command ${interaction.commandName} but the bot had no permission to join/speak in the voice channel.`
);
return true;
}
return false;
};
exports.cannotSendMessageInChannel = async (interaction) => {
const channel = interaction.channel;
// only checks if channel is viewable, as bot will have permission to send interaction replies if channel is viewable
if (!channel.viewable) {
// we can still send ephemeral replies in channels we can't view, so sending message to user instead
await interaction.deferReply({ ephemeral: true });
await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to send message replies in the channel you are in.\n\nPlease make sure I have the **\`View Channel\`** permission in this text channel.`
)
.setColor(embedOptions.colors.warning)
],
ephemeral: true
});
logger.debug(
`User tried to use command ${interaction.commandName} but the bot had no permission to send reply in text channel.`
);
return true;
}