Keep the queue across restarts; add shuffle, loop, renaming and live events
- Save the queue to storage/runtime/queue.json and restore it at startup, the interrupted track first; playback resumes once someone is in the voice channel. Shutdown keeps the queued files instead of deleting them. - Shuffle the upcoming tracks; loop mode sends finished tracks back to the end of the queue, except removed or failed ones. - Rename library tracks (queued copies follow), enqueue the whole library, optionally shuffled. - Stream queue and library changes to the web page with Server-Sent Events (GET /api/events). - Sanitise the requester name sent when queueing a library track. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
39d2b6acfb
commit
9fb54798dd
12 changed files with 390 additions and 18 deletions
7
index.js
7
index.js
|
|
@ -4,6 +4,7 @@ import path from "path";
|
|||
import { fileURLToPath } from "url";
|
||||
import { config } from "./src/config.js";
|
||||
import { MusicQueue } from "./src/music/queue.js";
|
||||
import { createQueuePersistence } from "./src/music/queuePersistence.js";
|
||||
import { startWebServer } from "./src/web/server.js";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
|
|
@ -56,7 +57,11 @@ for (const file of eventFiles) {
|
|||
}
|
||||
}
|
||||
|
||||
const musicQueue = new MusicQueue(client);
|
||||
const musicQueue = new MusicQueue(client, {
|
||||
persistence: createQueuePersistence(
|
||||
path.join(process.cwd(), "storage", "runtime", "queue.json")
|
||||
),
|
||||
});
|
||||
// Les commandes du jukebox (/play, /skip, /queue) y accèdent par interaction.client.
|
||||
client.musicQueue = musicQueue;
|
||||
await client.login(config.token);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue