Fix vulnerable deps, shutdown and game server colours; tidy commands
All checks were successful
Deploy Palico Bot / check (push) Successful in 9s
Deploy Palico Bot / deploy (push) Successful in 6s

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:
Shinuwa 2026-11-29 19:59:08 +01:00
parent 60080df7dc
commit e08dba41a3
30 changed files with 638 additions and 643 deletions

View file

@ -1,55 +1,28 @@
import { REST, Routes } from "discord.js";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { REST, Routes } from "discord.js";
import { config } from "./src/config.js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const commands = [];
const foldersPath = path.join(__dirname, "src/commands");
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
if (folder.indexOf("[disabled]") === -1 || config.environnement === "test") {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const commandFile = await import(filePath);
if ("data" in commandFile.command && "execute" in commandFile.command) {
commands.push(commandFile.command.data.toJSON());
} else {
console.log(
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
);
}
}
}
}
const rest = new REST().setToken(config.token);
(async () => {
try {
console.log(
`Started refreshing ${commands.length} application (/) commands.`
);
const data = await rest.put(
Routes.applicationGuildCommands(
config.applicationId,
config.discordGuildId
),
{ body: commands }
);
console.log(
`Successfully reloaded ${data.length} application (/) commands.`
);
import { loadCommands } from "./src/loadCommands.js";
const commands = (await loadCommands()).map((command) => command.data.toJSON());
const rest = new REST().setToken(config.token);
(async () => {
try {
console.log(
`Started refreshing ${commands.length} application (/) commands.`
);
const data = await rest.put(
Routes.applicationGuildCommands(
config.applicationId,
config.discordGuildId
),
{ body: commands }
);
console.log(
`Successfully reloaded ${data.length} application (/) commands.`
);
} catch (error) {
console.error(error);
process.exitCode = 1;