feat: Added common logic for validating command execution

This commit is contained in:
Marius Begby committed 2023-07-18 14:53:07 +02:00
1 parent 780d6f4de3
commit c7400f9fcd
16 files changed
+155 -244

No files matched your search

+4 -11
View File
@@ -1,4 +1,5 @@
const { embedOptions, playerOptions } = require('../../config');
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidation');
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
@@ -9,20 +10,12 @@ module.exports = {
.setDMPermission(false)
.addNumberOption((option) => option.setName('page').setDescription('Page number of the queue').setMinValue(1)),
execute: async ({ interaction }) => {
if (!interaction.member.voice.channel) {
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**${embedOptions.icons.warning} Oops!**\nYou need to be in a voice channel to use this command.`
)
.setColor(embedOptions.colors.warning)
]
});
if (await notInVoiceChannel(interaction)) {
return;
}
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
const queue = useQueue(interaction.guild.id);
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
let queueString = '';
if (!queue) {