mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
feat: Added common logic for validating command execution
This commit is contained in:
1 parent
780d6f4de3
commit
c7400f9fcd
16 files changed
+155
-244
No files matched your search
@@ -1,4 +1,6 @@
|
||||
const { embedOptions } = require('../../config');
|
||||
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidation');
|
||||
const { queueDoesNotExist } = require('../../utils/validation/queueValidation');
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
|
||||
@@ -15,30 +17,14 @@ module.exports = {
|
||||
.setRequired(true)
|
||||
),
|
||||
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 queue = useQueue(interaction.guild.id);
|
||||
|
||||
if (!queue) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nThere are no tracks in the queue and nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
if (await queueDoesNotExist(interaction, queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const removeTrackNumber = interaction.options.getNumber('tracknumber');
|
||||
|
||||
Reference in new issue
Block a user