Fix vulnerable deps, shutdown and game server colours; tidy commands
Fixes:
- Update dependencies within their ranges: npm audit reported 8
vulnerabilities (proxy-addr, multer, body-parser, undici...), now 0.
- Close open connections on shutdown: an open jukebox page kept its
/api/events stream alive, so every restart waited for the 10 s
forced exit and ended with code 1.
- Restore the ANSI escape characters of the game servers message, lost
in a269824 (the status showed "[2;32mOnline[0m" as plain text). They
are now written as \u001b so they cannot silently disappear again.
- Rename MusicQueue.listeners(), which shadowed EventEmitter's own
listeners(eventName), to humanListeners().
- Deploy: check the VM's SSH host key (new DEPLOY_KNOWN_HOSTS secret)
instead of StrictHostKeyChecking=no; run checks on push only, since
PR branches are already checked by their push.
Commands:
- /listcommand is built from the loaded commands and their descriptions.
- /deletemsgs reports messages older than 14 days that it cannot delete.
- Vocal commands act on the caller's voice channel, falling back to
VOICE_CHANNEL_ID.
- /maketeam accepts comma-separated names, so names can contain spaces.
- The game servers message is edited whenever its content changes, and
a failed first update is retried instead of stopping the refresh.
Cleanup:
- Shared command loader (src/loadCommands.js); drop the unused
"[disabled]" folders mechanism and the NODE_ENV requirement.
- SHINUWA_USER_ID becomes OWNER_USER_ID (the old name still works).
- One shuffle helper instead of three copies; remove dead code
(validateAudioFile, PORT fallback, needless async).
- README: prerequisites first, consistent Node version, deploy secrets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
60080df7dc
commit
e08dba41a3
30 changed files with 638 additions and 643 deletions
|
|
@ -12,6 +12,7 @@ import {
|
|||
} from "@discordjs/voice";
|
||||
import { Events } from "discord.js";
|
||||
import { config } from "../config.js";
|
||||
import { shuffle } from "../features/utilities.js";
|
||||
import { createOpusStream } from "../media/validateAudioFile.js";
|
||||
import { serializeTrack, serializeTracks } from "../web/serializers.js";
|
||||
import {
|
||||
|
|
@ -306,7 +307,7 @@ class MusicQueue extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
async remove(trackId) {
|
||||
remove(trackId) {
|
||||
const index = this.queue.findIndex((track) => track.id === trackId);
|
||||
if (index === -1) {
|
||||
if (this.currentTrack && this.currentTrack.id === trackId) {
|
||||
|
|
@ -356,13 +357,7 @@ class MusicQueue extends EventEmitter {
|
|||
|
||||
// Mélange les morceaux à venir (le morceau en cours n'est pas touché).
|
||||
shuffle() {
|
||||
for (let index = this.queue.length - 1; index > 0; index--) {
|
||||
const randomIndex = Math.floor(Math.random() * (index + 1));
|
||||
[this.queue[index], this.queue[randomIndex]] = [
|
||||
this.queue[randomIndex],
|
||||
this.queue[index],
|
||||
];
|
||||
}
|
||||
shuffle(this.queue);
|
||||
this.emit("queueUpdate", this.snapshot());
|
||||
return this.snapshot();
|
||||
}
|
||||
|
|
@ -546,7 +541,7 @@ class MusicQueue extends EventEmitter {
|
|||
}
|
||||
|
||||
// Membres humains du salon configuré, sans le bot lui-même ni les autres bots.
|
||||
listeners() {
|
||||
humanListeners() {
|
||||
const channel = this.client.channels.cache.get(config.voiceChannelId);
|
||||
const clientId = this.client.user?.id;
|
||||
if (!channel || !clientId) {
|
||||
|
|
@ -559,7 +554,7 @@ class MusicQueue extends EventEmitter {
|
|||
}
|
||||
|
||||
hasListeners() {
|
||||
return (this.listeners()?.length ?? 0) > 0;
|
||||
return (this.humanListeners()?.length ?? 0) > 0;
|
||||
}
|
||||
|
||||
isBotAlone() {
|
||||
|
|
@ -569,7 +564,7 @@ class MusicQueue extends EventEmitter {
|
|||
return false;
|
||||
}
|
||||
|
||||
return this.listeners().length === 0;
|
||||
return this.humanListeners().length === 0;
|
||||
}
|
||||
|
||||
// Avec la persistance, la file (morceau en cours en tête) est enregistrée et ses fichiers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue