all repos — simple-discord-music-bot @ 3df93a72ede8d6132fe3d3ccb0ff5f2fdaf949c8

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

src/commands/clear.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('clear')
 8        .setDescription('Clear the queue.'),
 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        queue.clear()
17        return await interaction.reply({ content: 'Queue cleared.' });
18    },
19};