mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
fix: add validation to component interactions
This commit is contained in:
1 parent
5bc0239cdf
commit
7053f01bc5
8 files changed
+89
-36
No files matched your search
@@ -1,13 +1,5 @@
|
||||
import config from 'config';
|
||||
import {
|
||||
ChatInputCommandInteraction,
|
||||
EmbedBuilder,
|
||||
GuildMember,
|
||||
InteractionType,
|
||||
MessageComponentInteraction,
|
||||
TextChannel,
|
||||
VoiceChannel
|
||||
} from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember, InteractionType, TextChannel, VoiceChannel } from 'discord.js';
|
||||
|
||||
import loggerModule from '../../services/logger';
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
@@ -25,6 +17,8 @@ export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: Cannot
|
||||
});
|
||||
|
||||
const channel = interaction.member instanceof GuildMember ? interaction.member.voice.channel : null;
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
|
||||
if (channel instanceof VoiceChannel && (!channel.joinable || !channel.speakable)) {
|
||||
await interaction.editReply({
|
||||
@@ -38,7 +32,7 @@ export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: Cannot
|
||||
});
|
||||
|
||||
logger.debug(
|
||||
`User tried to use command '${interaction.commandName}' but the bot had no permission to join/speak in the voice channel.`
|
||||
`User tried to use command '${interactionIdentifier}' but the bot had no permission to join/speak in the voice channel.`
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user