all repos — simple-discord-music-bot @ 5fded05bd1b192407fad78e1406f688388b5f62e

A Discord bot making use of discord.js and play-yt.

src/commands/stop.ts (view raw)

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