discord-multipurpose-bot/commands/music/stop.js
Ayden cb5a906850
Some checks are pending
Docker / build (push) Waiting to run
Feat/Add Music Commands (#1)
* add simple music functionality

* update workflow

* update Dockerfile

* update Dockerfile

* update Dockerfile

* update Dockerfile

* add few more music commands

* add lyrics command

* update lyrics command

* add loop, and add categories to all commands

* change discord status

* seperate distube and change startup console theme

* Update README

* UPDATE LICENSE file

* fix docker compose image, add better error handling for distube and update tagging workflow

* switch to node-alpine image for docker

* switch to node-alpine image for docker

* update ascii

* music commands imporvements, implement live lyrics, some guards and bot leaving on empty

* use ffmpeg package rather than ffmpeg-static
2025-09-21 01:26:18 +01:00

51 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { SlashCommandBuilder } = require("discord.js");
const { requireVC } = require("../../utils/musicGuards");
module.exports = {
data: new SlashCommandBuilder()
.setName("stop")
.setDescription(
"Stops playback, clears the queue, and leaves the voice channel."
),
category: "Music",
async execute(interaction, client) {
try {
await interaction.deferReply();
const vc = requireVC(interaction);
const queue = client.distube.getQueue(interaction.guildId);
if (!queue) {
return interaction.followUp({
content: " Nothing is playing.",
ephemeral: true,
});
}
// Clear the queue and stop playback
// In DisTube v5, `queue.stop()` stops playback and clears upcoming songs.
queue.stop();
// Leave the voice channel via manager (recommended)
client.distube.voices.leave(interaction.guildId);
// If you use live lyrics, clean up the thread
try {
const live = require("../../utils/liveLyricsManager");
await live.stop(interaction.guildId, { deleteThread: true });
} catch {}
return interaction.followUp(
"⏹️ Stopped playback, cleared the queue, and left the voice channel."
);
} catch (e) {
console.error("stop command failed:", e);
const msg = e?.message || "❌ Failed to stop playback.";
if (interaction.deferred || interaction.replied) {
return interaction.followUp({ content: msg, ephemeral: true });
}
return interaction.reply({ content: msg, ephemeral: true });
}
},
};