UNPKG

@getsolara/solara.voice

Version:

Optional voice functionality for @getsolara/solara.js using @discordjs/voice

33 lines (29 loc) 1.58 kB
module.exports = { name: "$voiceQueueList", description: "Returns the current queue (limited length). Args: [limit=10];[separator=\\n]", takesBrackets: true, execute: async (context, args) => { if (context.client.voiceInitialized === false) { return "Queue is empty (Voice features disabled)."; } if (!context.guild) return "[Error: $voiceQueueList can only be used in a server.]"; const limit = args[0] ? parseInt(args[0], 10) : 10; const separator = args[1] !== undefined ? String(args[1]).replace(/\\n/g, '\n') : '\n'; if (isNaN(limit) || limit < 1) return "[Error: Invalid limit for $voiceQueueList. Must be a positive number.]"; const queue = context.client.solaraVoiceQueues?.get(context.guild.id); const nowPlaying = context.client.solaraNowPlaying?.get(context.guild.id); let output = ""; if (nowPlaying) { output += `Now Playing: ${nowPlaying.title || 'Unknown Title'} (${nowPlaying.duration || 'N/A'})${separator}`; } if (!queue || queue.length === 0) { return nowPlaying ? output.trim() : "Queue is empty."; } const queueList = queue.slice(0, limit).map((song, i) => `${i + 1}. ${song.title || 'Unknown Title'} (${song.duration || 'N/A'})`).join(separator); output += queueList; if (queue.length > limit) { output += `${separator}...and ${queue.length - limit} more.`; } return output.trim() || "Queue is empty."; } };