discord-multipurpose-bot/commands/music/livelyrics.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

81 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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, PermissionFlagsBits } = require("discord.js");
const { requireVC, requireQueue } = require("../../utils/musicGuards");
module.exports = {
data: new SlashCommandBuilder()
.setName("livelyrics")
.setDescription(
"Show synced lyrics in a live thread for the current track."
)
.addSubcommand((sc) =>
sc
.setName("start")
.setDescription("Start live lyrics for the currently playing song.")
.addBooleanOption((o) =>
o
.setName("newthread")
.setDescription(
"Force a new thread even if one exists (default: reuse)."
)
)
)
.addSubcommand((sc) =>
sc
.setName("stop")
.setDescription("Stop live lyrics and remove the thread.")
),
category: "Music",
async execute(interaction, client) {
try {
await interaction.deferReply();
const sub = interaction.options.getSubcommand();
// Make sure user is in/with the VC and there is a queue
requireVC(interaction);
const queue = requireQueue(client, interaction);
// Lazy-load manager to avoid circular requires on startup
const live = require("../../utils/liveLyricsManager");
if (sub === "start") {
const forceNew = interaction.options.getBoolean("newthread") ?? false;
// If a thread is already running and user didn't force, just re-sync and say it's on
if (!forceNew) {
// Re-sync to current time if already active (no-op otherwise)
await live.resume(queue);
await live.seek(queue);
} else {
// Ensure any old thread is removed before starting a new one
await live.stop(queue.id, { deleteThread: true });
}
const song = queue.songs?.[0];
if (!song) {
return interaction.followUp("❌ Nothing is playing.");
}
await live.start(queue, song);
return interaction.followUp(
"🎤 Live lyrics started. Ill post lines in a thread (or here if I cant create one)."
);
} else if (sub === "stop") {
await live.stop(queue.id, { deleteThread: true });
return interaction.followUp(
"🧹 Stopped live lyrics and removed the thread."
);
}
return interaction.followUp("❌ Unknown subcommand.");
} catch (e) {
const msg = e?.message ?? "❌ Failed to run /livelyrics.";
if (interaction.deferred || interaction.replied) {
await interaction.followUp({ content: msg, ephemeral: true });
} else {
await interaction.reply({ content: msg, ephemeral: true });
}
}
},
};