all repos — simple-discord-music-bot @ 740c3a8bc78d682b36adacd3beaa08c338ed2ccb

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

commands/queue.js (view raw)

 1const { SlashCommandBuilder } = require('discord.js');
 2const { getChannel, getQueue } = require('../functions/music');
 3
 4module.exports = {
 5    data: new SlashCommandBuilder()
 6        .setName('queue')
 7        .setDescription('Show current queue status.'),
 8
 9    async execute(interaction) {
10        const channel = await getChannel(interaction);
11        if (typeof channel == 'string')
12            return await interaction.reply({ content: channel, ephemeral: true });
13
14        const result = await getQueue();
15        if (result) {
16            let finalReply = "Now playing: " + result.shift() + "\n";
17            
18            for (r in result) {
19                finalReply += "\n" + (r + 1) + ". " + result[r];
20            }
21            return await interaction.reply({ content: finalReply });
22        }
23        return await interaction.reply({ content: 'Queue is empty.' });
24    },
25};