mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 22:16:13 +00:00
fix: Added check on text channel permissions on intereactionCreate
This commit is contained in:
1 parent
b68b7dac95
commit
0c7a627e83
2 files changed
+36
-2
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user