Added /leave command

This commit is contained in:
Marius Begby committed 2023-07-06 10:17:04 +02:00
1 parent 2e50e0d4fc
commit b07ef030bd
1 file changed
+52
+52
View File
@@ -0,0 +1,52 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useMainPlayer, useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('leave')
.setDescription(
'Clear the track queue and remove the bot from voice channel.'
),
run: async ({ interaction }) => {
if (!interaction.member.voice.channel) {
return interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**Error**\nYou need to be in a voice channel to use this command.`
)
.setColor('#c70057')
]
});
}
const queue = useQueue(interaction.guild.id);
if (!queue) {
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**Error**\nNo tracks are currently playing, and the queue is empty. Use the \`/play\` command to play some music!`
)
.setColor('#c70057')
]
});
}
if (!queue.deleted) {
queue.delete();
await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**Leaving**\nCleared the track queue and left voice channel. To play more music, use the \`/play\` command!`
)
.setColor('#4c73df')
]
});
}
}
};