src/commands/stop.ts (view raw)
1import { SlashCommandBuilder, ChatInputCommandInteraction } from 'discord.js';
2import { getQueue } from '../functions/music';
3import { getChannel } from '../functions/voice';
4
5module.exports = {
6 data: new SlashCommandBuilder()
7 .setName('stop')
8 .setDescription('Stop the music and leaves the voice channel.'),
9
10 async execute(interaction: ChatInputCommandInteraction) {
11 const channel = await getChannel(interaction);
12 if (typeof channel == 'string')
13 return await interaction.reply({ content: channel, ephemeral: true });
14
15 const queue = getQueue(interaction.guildId);
16 const r = queue.stop();
17 if (r)
18 return await interaction.reply({ content: 'Stopped.' });
19
20 return await interaction.reply({ content: 'Error.', ephemeral: true });
21 },
22};