UNPKG

@getsolara/solara.voice

Version:

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

34 lines (32 loc) 1.49 kB
module.exports = { name: "$voiceStop", description: "Stops playback, clears the queue, and leaves the voice channel.", takesBrackets: false, execute: async (context, args) => { if (context.client.voiceInitialized === false) { return "[Error: $voiceStop requires voice features to be enabled. Ensure @getsolara/solara.voice is installed and configured correctly.]"; } if (!context.guild) return "[Error: $voiceStop can only be used in a server.]"; const guildId = context.guild.id; const player = context.client.solaraAudioPlayers?.get(guildId); const connection = context.client.solaraVoiceConnections?.get(guildId); if (player) { player.stop(true); context.client.solaraAudioPlayers.delete(guildId); } const queue = context.client.solaraVoiceQueues?.get(guildId); if (queue) { queue.length = 0; } context.client.solaraNowPlaying?.delete(guildId); if (connection) { try { const { VoiceConnectionStatus } = require('@discordjs/voice'); if (connection.state.status !== VoiceConnectionStatus.Destroyed) { connection.destroy(); } } catch (e) { /* Ignore module not found here as we are just destroying */ } } return "Playback stopped, queue cleared, and left voice channel."; } };