mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 06:28:53 +00:00
54 lines
2.1 KiB
JavaScript
54 lines
2.1 KiB
JavaScript
const logger = require('../../services/logger');
|
|
const { embedOptions } = require('../../config');
|
|
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidation');
|
|
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
|
const { useQueue } = require('discord-player');
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('leave')
|
|
.setDescription('Clear the track queue and remove the bot from voice channel.')
|
|
.setDMPermission(false),
|
|
|
|
// todo, allow command to be executed if bot is only member in voice channel
|
|
execute: async ({ interaction }) => {
|
|
if (await notInVoiceChannel(interaction)) {
|
|
return;
|
|
}
|
|
|
|
const queue = useQueue(interaction.guild.id);
|
|
|
|
if (!queue) {
|
|
logger.debug(`User used command ${interaction.commandName} but there was no queue.`);
|
|
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 (!queue.deleted) {
|
|
queue.delete();
|
|
logger.debug(`User used command ${interaction.commandName} and deleted the queue.`);
|
|
|
|
return await interaction.editReply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setAuthor({
|
|
name: interaction.member.nickname || interaction.user.username,
|
|
iconURL: interaction.user.avatarURL()
|
|
})
|
|
.setDescription(
|
|
`**${embedOptions.icons.success} Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the **\`/play\`** command!`
|
|
)
|
|
.setColor(embedOptions.colors.success)
|
|
]
|
|
});
|
|
}
|
|
}
|
|
};
|