Add tracks from a direct link and from Discord with /play, /skip, /queue
- Download direct audio links server side (web page and /play), refusing internal and special addresses at connection time and after every redirect, with size and time limits. - /play takes an attachment, a direct link or a library track (autocomplete), and can keep the file in the library; /skip and /queue control and show the shared queue. - Share one ingest path between uploads, links and Discord attachments. - Answer 413 instead of 500 when the library is full. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
98f4d29ac7
commit
39d2b6acfb
14 changed files with 715 additions and 54 deletions
41
src/commands/jukebox/queue.js
Normal file
41
src/commands/jukebox/queue.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { MessageFlags, SlashCommandBuilder, escapeMarkdown } from "discord.js";
|
||||
import { trackLabel } from "../../features/formatTrack.js";
|
||||
|
||||
const SHOWN_TRACKS = 10;
|
||||
|
||||
function buildQueueMessage(queue) {
|
||||
const lines = [];
|
||||
lines.push(
|
||||
queue.currentTrack
|
||||
? `🎶 En cours : **${escapeMarkdown(trackLabel(queue.currentTrack))}**`
|
||||
: "🎶 Rien en cours de lecture."
|
||||
);
|
||||
|
||||
if (queue.queue.length === 0) {
|
||||
lines.push("La file est vide. Ajoute un morceau avec `/play`.");
|
||||
} else {
|
||||
lines.push("", "__À suivre__ :");
|
||||
queue.queue.slice(0, SHOWN_TRACKS).forEach((track, index) => {
|
||||
lines.push(`${index + 1}. ${escapeMarkdown(trackLabel(track))}`);
|
||||
});
|
||||
const hidden = queue.queue.length - SHOWN_TRACKS;
|
||||
if (hidden > 0) {
|
||||
lines.push(`… et ${hidden} autre(s).`);
|
||||
}
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
const command = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("queue")
|
||||
.setDescription("Affiche la file d'attente du jukebox"),
|
||||
async execute(interaction) {
|
||||
await interaction.reply({
|
||||
content: buildQueueMessage(interaction.client.musicQueue),
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export { buildQueueMessage, command };
|
||||
Loading…
Add table
Add a link
Reference in a new issue