mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
fix: update validation in interactions
This commit is contained in:
1 parent
37546405e2
commit
5bc0239cdf
17 files changed
+162
-217
No files matched your search
@@ -6,6 +6,7 @@ import loggerModule from '../../../services/logger';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
|
||||
@@ -27,29 +28,18 @@ const command: CustomSlashCommandInteraction = {
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
}
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (!queue) {
|
||||
logger.debug('There is no queue.');
|
||||
const validators = [
|
||||
() => notInVoiceChannel({ interaction, executionId }),
|
||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
||||
() => queueDoesNotExist({ interaction, queue, executionId })
|
||||
];
|
||||
|
||||
logger.debug('Responding with warning embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\n_Hmm.._ It seems I am not in a voice channel!`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
for (const validator of validators) {
|
||||
if (await validator()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!queue.deleted) {
|
||||
|
||||
Reference in new issue
Block a user