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,6 +1,6 @@
NODE_ENV=test
DISCORD_GUILD_ID=
SHINUWA_USER_ID=
# Personne qui gère les serveurs de jeux, mentionnée dans leur message (ancien nom : SHINUWA_USER_ID).
OWNER_USER_ID=
WEB_SERVER_PORT=3000
WEB_API_KEY=
DISCORD_APPLICATION_ID=

View file

@ -1,10 +1,10 @@
name: Deploy Palico Bot
# Les contrôles tournent sur chaque branche ; le déploiement, seulement après un push sur
# main dont les contrôles ont réussi.
# Les contrôles tournent à chaque push, sur toutes les branches (une PR est donc contrôlée par
# le push de sa branche) ; le déploiement, seulement après un push sur main dont les
# contrôles ont réussi.
on:
push:
pull_request:
jobs:
check:
@ -32,6 +32,9 @@ jobs:
- name: Deploy on WebApps
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
# Clé d'hôte de la VM (sortie de `ssh-keyscan -p 2911 192.168.0.100`) : sans elle,
# n'importe quelle machine qui répondrait à cette adresse recevrait la connexion.
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
run: |
# L'image contient déjà le client SSH ; ne l'installer que s'il manque.
if ! command -v ssh >/dev/null; then
@ -39,11 +42,17 @@ jobs:
apt-get install -y --no-install-recommends openssh-client
fi
if [ -z "$DEPLOY_KNOWN_HOSTS" ]; then
echo "Secret DEPLOY_KNOWN_HOSTS manquant (ssh-keyscan -p 2911 192.168.0.100)" >&2
exit 1
fi
mkdir -p ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/id_ed25519
ssh -o StrictHostKeyChecking=no \
ssh -o StrictHostKeyChecking=yes \
-i ~/.ssh/id_ed25519 \
-p 2911 \
shinuwa@192.168.0.100 \

View file

@ -1,5 +1,20 @@
# palico-bot
## Prérequis
- Node.js 22.12 ou supérieur (prise en charge du protocole vocal DAVE de Discord) ;
`.nvmrc` indique la version utilisée pour le développement ;
- FFmpeg et FFprobe disponibles dans le `PATH` ;
- accès UDP sortant vers les serveurs vocaux Discord.
Sur Debian ou Ubuntu :
```bash
sudo apt install ffmpeg
npm ci
npm run check
```
## Configuration
La configuration sensible est stockée dans un fichier `.env` exclu de Git.
@ -23,23 +38,6 @@ npm start
npm run deploy
```
Node.js 22.12 ou supérieur est nécessaire pour la prise en charge du protocole
vocal DAVE de Discord.
## Prérequis
- Node.js 24 LTS ;
- FFmpeg et FFprobe disponibles dans le `PATH` ;
- accès UDP sortant vers les serveurs vocaux Discord.
Sur Debian ou Ubuntu :
```bash
sudo apt install ffmpeg
npm ci
npm run check
```
## Données persistantes
Le dossier `storage/` est une donnée applicative et ne doit pas être remplacé
@ -71,6 +69,13 @@ contrôles réussissent, il se connecte ensuite en SSH à la VM et exécute
`/usr/local/bin/deploy-palico-bot` (mise à jour du dépôt, dépendances, redémarrage
du service `palico-bot`).
Secrets du dépôt : `DEPLOY_SSH_KEY` (clé privée de déploiement) et
`DEPLOY_KNOWN_HOSTS`, la clé d'hôte de la VM, vérifiée à la connexion :
```bash
ssh-keyscan -p 2911 192.168.0.100
```
Supervision : `/healthz` répond dès que le processus tourne ; `/readyz` répond
`503` tant que le bot n'est pas connecté à Discord.
@ -123,6 +128,15 @@ le serveur garde l'accès jusqu'à l'expiration de sa session ; changer
Après l'ajout ou la modification d'une commande, relancer `npm run deploy` pour
les enregistrer auprès de Discord.
## Commandes
`/listcommand` affiche les commandes chargées, rangées par dossier de
`src/commands` ; une nouvelle commande y apparaît avec sa description.
`/muteall`, `/unmuteall`, `/deafall` et `/undeafall` agissent sur le salon vocal
de la personne qui lance la commande, ou sur `VOICE_CHANNEL_ID` si elle n'est
dans aucun salon.
## Invitations
Les membres ne peuvent pas créer d'invitation : un seul lien, à adhésion

View file

@ -1,35 +1,8 @@
import { REST, Routes } from "discord.js";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { config } from "./src/config.js";
import { loadCommands } from "./src/loadCommands.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 commands = (await loadCommands()).map((command) => command.data.toJSON());
const rest = new REST().setToken(config.token);

View file

@ -3,6 +3,7 @@ import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { config } from "./src/config.js";
import { loadCommands } from "./src/loadCommands.js";
import { MusicQueue } from "./src/music/queue.js";
import { createQueuePersistence } from "./src/music/queuePersistence.js";
import { startWebServer } from "./src/web/server.js";
@ -14,29 +15,9 @@ const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates],
});
client.commands = new Collection();
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) {
client.commands.set(commandFile.command.data.name, commandFile);
} else {
console.log(
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
);
}
}
}
}
client.commands = new Collection(
(await loadCommands()).map((command) => [command.data.name, command])
);
const eventsPath = path.join(__dirname, "src/events");
const eventFiles = fs
@ -87,6 +68,9 @@ async function shutdown(signal) {
server.close(() => {
clearTimeout(forceExit);
});
// close() n'attend que la fin des requêtes en cours : les flux en direct (/api/events) des
// pages jukebox ouvertes ne finissent jamais d'eux-mêmes et bloqueraient l'arrêt.
server.closeAllConnections();
}
process.once("SIGTERM", () => void shutdown("SIGTERM"));

474
package-lock.json generated
View file

@ -22,15 +22,15 @@
}
},
"node_modules/@discordjs/builders": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.14.1.tgz",
"integrity": "sha512-gSKkhXLqs96TCzk66VZuHHl8z2bQMJFGwrXC0f33ngK+FLNau4hU1PYny3DNJfNdSH+gVMzE85/d5FQ2BpcNwQ==",
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.15.0.tgz",
"integrity": "sha512-AifaDWTw6WUDhKBn8E6mwwoyjDAcfsYq+ZE0nKSu1dMH1NLR22D3hGkNx+ctEv8NqHEHdAZnP5REteHDmn1lkA==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/formatters": "^0.6.2",
"@discordjs/util": "^1.2.0",
"@sapphire/shapeshift": "^4.0.0",
"discord-api-types": "^0.38.40",
"discord-api-types": "^0.38.50",
"fast-deep-equal": "^3.1.3",
"ts-mixer": "^6.0.4",
"tslib": "^2.6.3"
@ -67,9 +67,9 @@
}
},
"node_modules/@discordjs/rest": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.6.1.tgz",
"integrity": "sha512-wwQdgjeaoYFiaG+atbqx6aJDpqW7JHAo0HrQkBTbYzM3/PJ3GweQIpgElNcGZ26DCUOXMyawYd0YF7vtr+fZXg==",
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.6.3.tgz",
"integrity": "sha512-wvOylxNYJkwKjctS/Mn5GP1w9r3/rzyH+ThD1JlAca6zEdlHs8QWBBUQJpU5Q+W6DoIj/Ljh1IPlZs7hTU+UAg==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/collection": "^2.1.1",
@ -77,10 +77,10 @@
"@sapphire/async-queue": "^1.5.3",
"@sapphire/snowflake": "^3.5.5",
"@vladfrangu/async_event_emitter": "^2.4.6",
"discord-api-types": "^0.38.40",
"discord-api-types": "^0.38.50",
"magic-bytes.js": "^1.13.0",
"tslib": "^2.6.3",
"undici": "6.24.1"
"undici": "^6.27.0"
},
"engines": {
"node": ">=18"
@ -101,16 +101,6 @@
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/rest/node_modules/@sapphire/snowflake": {
"version": "3.5.5",
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.5.tgz",
"integrity": "sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@discordjs/util": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.2.0.tgz",
@ -182,21 +172,21 @@
}
},
"node_modules/@emnapi/core": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.1.tgz",
"integrity": "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==",
"version": "1.11.3",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.3.tgz",
"integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==",
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"@emnapi/wasi-threads": "1.2.2",
"@emnapi/wasi-threads": "1.2.3",
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.1.tgz",
"integrity": "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==",
"version": "1.11.3",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
"integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
"license": "MIT",
"optional": true,
"peer": true,
@ -205,9 +195,9 @@
}
},
"node_modules/@emnapi/wasi-threads": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz",
"integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==",
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz",
"integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==",
"license": "MIT",
"optional": true,
"peer": true,
@ -216,21 +206,24 @@
}
},
"node_modules/@napi-rs/wasm-runtime": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.6.tgz",
"integrity": "sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==",
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.7.tgz",
"integrity": "sha512-zJccwplOAbgfZju95IUHazLnx9RAPtPN2YGJXI6UbrgeaR9QfPjGrQL6ERkSAtnVCA4Q+83ApGyaX5zdpCaKkQ==",
"license": "MIT",
"optional": true,
"dependencies": {
"@tybys/wasm-util": "^0.10.3"
},
"engines": {
"node": "^20.19.0 || ^22.13.0 || >=23.5.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
},
"peerDependencies": {
"@emnapi/core": "^1.7.1",
"@emnapi/runtime": "^1.7.1"
"@emnapi/core": "^1.7.1 || 2.0.0-beta.2 || 2.0.0-beta.3",
"@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2 || 2.0.0-beta.3"
}
},
"node_modules/@sapphire/async-queue": {
@ -257,9 +250,9 @@
}
},
"node_modules/@sapphire/snowflake": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.3.tgz",
"integrity": "sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==",
"version": "3.5.5",
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.5.tgz",
"integrity": "sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",
@ -531,9 +524,9 @@
}
},
"node_modules/@tybys/wasm-util": {
"version": "0.10.3",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz",
"integrity": "sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==",
"version": "0.10.5",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz",
"integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==",
"license": "MIT",
"optional": true,
"dependencies": {
@ -541,18 +534,18 @@
}
},
"node_modules/@types/node": {
"version": "24.10.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz",
"integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==",
"version": "26.6.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.11.tgz",
"integrity": "sha512-uUyQ2XLEz+EXh34lmS3GhKrkqn/8FU7KUiKRpk347At2bmnMVWss45yz8b4FG/tUtmV1tV/+TVkITItPROyeeQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~7.16.0"
"undici-types": "~8.9.0"
}
},
"node_modules/@types/ws": {
"version": "8.18.1",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
"integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
"version": "8.18.2",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.2.tgz",
"integrity": "sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
@ -588,18 +581,18 @@
"license": "MIT"
},
"node_modules/body-parser": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",
"integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==",
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz",
"integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==",
"license": "MIT",
"dependencies": {
"bytes": "^3.1.2",
"content-type": "^2.0.0",
"content-type": "^2.1.0",
"debug": "^4.4.3",
"http-errors": "^2.0.1",
"iconv-lite": "^0.7.2",
"iconv-lite": "^0.7.3",
"on-finished": "^2.4.1",
"qs": "^6.15.2",
"qs": "^6.16.1",
"raw-body": "^3.0.2",
"type-is": "^2.1.0"
},
@ -611,25 +604,6 @@
"url": "https://opencollective.com/express"
}
},
"node_modules/body-parser/node_modules/content-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
"integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"license": "MIT"
},
"node_modules/busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
@ -679,40 +653,30 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/concat-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
"integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
"engines": [
"node >= 6.0"
],
"license": "MIT",
"dependencies": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^3.0.2",
"typedarray": "^0.0.6"
}
},
"node_modules/content-disposition": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz",
"integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-2.0.1.tgz",
"integrity": "sha512-e+H0ZXHSWYrENhQzw1LPuP4oF5MzVKmDU6d3hxlvaPEYLLg62MxtQNPRx4SYSuYJSBUgnQIG4HIN2tEtNv7Dog==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz",
"integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/cookie": {
@ -760,33 +724,30 @@
}
},
"node_modules/discord-api-types": {
"version": "0.38.49",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.49.tgz",
"integrity": "sha512-XnqcWmnFZFAE8ZM8SHAw9DIV8D3Or00rMQ8iQLotrEA2PmXhl+ykaf6L6q4l474hrSUH1JaYcv+iOMRWp2p6Tg==",
"license": "MIT",
"workspaces": [
"scripts/actions/documentation"
]
"version": "0.38.60",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.60.tgz",
"integrity": "sha512-2xPScuQP3WOf3H4EKWLzvnhlfNl8sBMD+krT8CcjMVJa6o9D/6ssOSgKPTvHyIhQDKUX+gvUJZ43U4HqE+6tsA==",
"license": "MIT"
},
"node_modules/discord.js": {
"version": "14.26.4",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.26.4.tgz",
"integrity": "sha512-4oBp8tc6Kf8IDBwAHhbsMaAqx1b5fob9SNasZT7V6yyyUydoO5i5fGuX7TmvRtR+q/WgKRnRViRoAWnG7fNyvA==",
"version": "14.28.1",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.28.1.tgz",
"integrity": "sha512-Je5OcqgurnIUQK4vR+gQnmzOf/lNQsD6d/UkV8ZOj+bFa5zJXPyiGXlbywp2EagwshVT18y7YNQNSRd3FjYkDw==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/builders": "^1.14.1",
"@discordjs/builders": "^1.15.0",
"@discordjs/collection": "1.5.3",
"@discordjs/formatters": "^0.6.2",
"@discordjs/rest": "^2.6.1",
"@discordjs/rest": "^2.6.3",
"@discordjs/util": "^1.2.0",
"@discordjs/ws": "^1.2.3",
"@sapphire/snowflake": "3.5.3",
"discord-api-types": "^0.38.40",
"@sapphire/snowflake": "3.5.5",
"discord-api-types": "^0.38.50",
"fast-deep-equal": "3.1.3",
"lodash.snakecase": "4.1.1",
"magic-bytes.js": "^1.13.0",
"tslib": "^2.6.3",
"undici": "6.24.1"
"undici": "^6.27.0"
},
"engines": {
"node": ">=18"
@ -816,12 +777,16 @@
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.3.tgz",
"integrity": "sha512-mIteYONiEfc4xWf2F1WXovh1c8npzS00vNeiUPdwFF+QlVJni+gNvpQltLMQhob8rew/bWWc/bGTuUr0EUGt0w==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/es-define-property": {
@ -870,15 +835,15 @@
}
},
"node_modules/express": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/express/-/express-5.3.0.tgz",
"integrity": "sha512-qCqy1xSoaugxOD4IVHb1ZWdkvCF2W3aE2okKouWj8VwJ+ztskSiXoBnCSJqfKT+cVPJhuJqe9YLbY425+Zh00g==",
"license": "MIT",
"dependencies": {
"accepts": "^2.0.0",
"body-parser": "^2.2.1",
"content-disposition": "^1.0.0",
"content-type": "^1.0.5",
"body-parser": "^2.3.0",
"content-disposition": "^2.0.1",
"content-type": "^2.0.0",
"cookie": "^0.7.1",
"cookie-signature": "^1.2.1",
"debug": "^4.4.0",
@ -894,14 +859,14 @@
"on-finished": "^2.4.1",
"once": "^1.4.0",
"parseurl": "^1.3.3",
"proxy-addr": "^2.0.7",
"qs": "^6.14.0",
"proxy-addr": "^2.0.8",
"qs": "^6.16.0",
"range-parser": "^1.2.1",
"router": "^2.2.0",
"send": "^1.1.0",
"serve-static": "^2.2.0",
"statuses": "^2.0.1",
"type-is": "^2.0.1",
"type-is": "^2.1.0",
"vary": "^1.1.2"
},
"engines": {
@ -913,11 +878,12 @@
}
},
"node_modules/express-rate-limit": {
"version": "8.5.2",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.5.2.tgz",
"integrity": "sha512-5Kb34ipNX694DH48vN9irak1Qx30nb0PLYHXfJgw4YEjiC3ZEmZJhwOp+VfiCYwFzvFTdB9QkArYS5kXa2cx2A==",
"version": "8.7.5",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.5.tgz",
"integrity": "sha512-wi+v38cx2EqD0JnhE/e74o5tFqKWUOAPFJIgyEiqJ8v2MNpoOAA3kI2hXYOI+YM+HE5yqbdAlVxm2GqOIeYOgA==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.3",
"ip-address": "^10.2.0"
},
"engines": {
@ -937,9 +903,9 @@
"license": "MIT"
},
"node_modules/finalhandler": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz",
"integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",
"integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.0",
@ -950,7 +916,11 @@
"statuses": "^2.0.1"
},
"engines": {
"node": ">= 0.8"
"node": ">= 18.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/forwarded": {
@ -1054,9 +1024,9 @@
}
},
"node_modules/helmet": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/helmet/-/helmet-8.2.0.tgz",
"integrity": "sha512-DRgTIUgnWcJ62KyarxxziuqYxKGnR6Rgg19BlbucN/dpmJbl1XOit6qvoOX0ZT+HhWe5OUVhU/a1zpGyc1xA0Q==",
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/helmet/-/helmet-8.3.0.tgz",
"integrity": "sha512-Qgpiaws3Sm30Av8Eah6sjMCZZwjlBu+E68rhpCWBshY1lb09HtLwj5GviX0OyQIn+ulUS0iX0AxN5n3tLZzz1w==",
"license": "MIT",
"engines": {
"node": ">=18.0.0"
@ -1086,9 +1056,9 @@
}
},
"node_modules/iconv-lite": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
"integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==",
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
"integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
@ -1108,9 +1078,9 @@
"license": "ISC"
},
"node_modules/ip-address": {
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz",
"integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==",
"version": "10.7.7",
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.7.tgz",
"integrity": "sha512-He15rAs4jip5AEAz7XM9L+S6Y8LBMIDj6YewbYuJfmDnOCKWb+3TLOGnHFBTAIW7wpm5ohtZ+Xyo5PEaG+O2vQ==",
"license": "MIT",
"engines": {
"node": ">= 12"
@ -1144,9 +1114,9 @@
"license": "MIT"
},
"node_modules/magic-bytes.js": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.13.0.tgz",
"integrity": "sha512-afO2mnxW7GDTXMm5/AoN1WuOcdoKhtgXjIvHmobqTD1grNplhGdv3PFOyjCVmrnOZBIT/gD/koDKpYG+0mvHcg==",
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.13.1.tgz",
"integrity": "sha512-x5sn4UX2k5gCWlcfmoFwG4TPie8+dctESyqOBdhB5p6MsgWXdBKGmt9nXPObj/JI50TTL928lc5Yt1WntMn1bw==",
"license": "MIT"
},
"node_modules/math-intrinsics": {
@ -1159,12 +1129,16 @@
}
},
"node_modules/media-typer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz",
"integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz",
"integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/merge-descriptors": {
@ -1189,15 +1163,19 @@
}
},
"node_modules/mime-types": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz",
"integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==",
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz",
"integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==",
"license": "MIT",
"dependencies": {
"mime-db": "^1.54.0"
},
"engines": {
"node": ">= 0.6"
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/ms": {
@ -1207,14 +1185,13 @@
"license": "MIT"
},
"node_modules/multer": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.2.0.tgz",
"integrity": "sha512-6rdyFg2kLrMh9Jee7/BMPuV9lEAd7lLW2YUpF9/YxR7njyoUwwQ0ZPh3TaIY50Sw6vlyD2HW3wGOkTS4P79xrQ==",
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.5.0.tgz",
"integrity": "sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==",
"license": "MIT",
"dependencies": {
"append-field": "^1.0.0",
"busboy": "^1.6.0",
"concat-stream": "^2.0.0",
"type-is": "^1.6.18"
},
"engines": {
@ -1269,18 +1246,25 @@
}
},
"node_modules/negotiator": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
"integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz",
"integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==",
"license": "MIT",
"dependencies": {
"content-type": "^2.1.0"
},
"engines": {
"node": ">= 0.6"
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.14.0.tgz",
"integrity": "sha512-IVgHNlp/jwQX271+Xzoq9LZNTWXxZK+cEOrGBOBxXNbn7fapnZ+Ts6TVMgNOuAezwG2wdtnMX97tTPK6VEnuOQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
@ -1290,15 +1274,19 @@
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz",
"integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/once": {
@ -1362,9 +1350,9 @@
}
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
"integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
@ -1372,12 +1360,16 @@
},
"engines": {
"node": ">= 0.10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/qs": {
"version": "6.15.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz",
"integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==",
"version": "6.17.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
"integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
"license": "BSD-3-Clause",
"dependencies": {
"es-define-property": "^1.0.1",
@ -1391,12 +1383,16 @@
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz",
"integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/raw-body": {
@ -1414,24 +1410,10 @@
"node": ">= 0.10"
}
},
"node_modules/readable-stream": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
"license": "MIT",
"dependencies": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/router": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
"integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/router/-/router-2.3.0.tgz",
"integrity": "sha512-bpowRfGjEPe8t9R6fJIzhwmyCGAXwKvxBUsgJm+bJukwdcWmUXbMo7p22w7aYmQBPQTUMNqMV39YX0kMou3z8w==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.0",
@ -1442,28 +1424,12 @@
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
@ -1471,31 +1437,35 @@
"license": "MIT"
},
"node_modules/send": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz",
"integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz",
"integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==",
"license": "MIT",
"dependencies": {
"debug": "^4.3.5",
"debug": "^4.4.3",
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"etag": "^1.8.1",
"fresh": "^2.0.0",
"http-errors": "^2.0.0",
"mime-types": "^3.0.1",
"http-errors": "^2.0.1",
"mime-types": "^3.0.2",
"ms": "^2.1.3",
"on-finished": "^2.4.1",
"range-parser": "^1.2.1",
"statuses": "^2.0.1"
"statuses": "^2.0.2"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/serve-static": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz",
"integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz",
"integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==",
"license": "MIT",
"dependencies": {
"encodeurl": "^2.0.0",
@ -1505,6 +1475,10 @@
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/setprototypeof": {
@ -1602,15 +1576,6 @@
"node": ">=10.0.0"
}
},
"node_modules/string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"license": "MIT",
"dependencies": {
"safe-buffer": "~5.2.0"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
@ -1627,9 +1592,9 @@
"license": "MIT"
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz",
"integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==",
"license": "0BSD"
},
"node_modules/type-is": {
@ -1650,38 +1615,19 @@
"url": "https://opencollective.com/express"
}
},
"node_modules/type-is/node_modules/content-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
"integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
"license": "MIT"
},
"node_modules/undici": {
"version": "6.27.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.27.0.tgz",
"integrity": "sha512-YmfV3YnEDzXRC5lZ2jWtWWHKGUm1zIt8AhesR1tens+HTNv+YZlN/dp6G727LOvMJ8xjP9Be7Y2Sdr96LDm+pg==",
"version": "6.29.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz",
"integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/undici-types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
"version": "8.9.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",
"integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
"license": "MIT"
},
"node_modules/unpipe": {
@ -1693,12 +1639,6 @@
"node": ">= 0.8"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"license": "MIT"
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
@ -1715,9 +1655,9 @@
"license": "ISC"
},
"node_modules/ws": {
"version": "8.21.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
"integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
"version": "8.23.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.23.1.tgz",
"integrity": "sha512-1rzWDSN0NOi3tpwgHsQExjWRoKUGtjCkJ2gZRaaRtzhYLboMytOI9pj9PU7yCgY37auqdd4OyLofZDbkeuZmPA==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"

View file

@ -9,7 +9,7 @@ const command = {
.addIntegerOption((option) =>
option
.setName("number")
.setDescription("Nombre de dés a lancer")
.setDescription("Nombre de dés à lancer")
.setMinValue(1)
.setMaxValue(20)
.setRequired(true)
@ -25,39 +25,36 @@ const command = {
async execute(interaction) {
const number = interaction.options.getInteger("number");
const faces = interaction.options.getInteger("faces");
var sum = 0;
var message = "Alors du coup... 🥁\n";
var tails = 0;
var heads = 0;
let sum = 0;
let message = "Alors du coup... 🥁\n";
let tails = 0;
let heads = 0;
if (faces === 2) {
message = message + subtext(`Pile = 1 et Face = 2\n`);
message += subtext("Pile = 1 et Face = 2\n");
}
await interaction.reply(message);
for (let i = 0; i < number; i++) {
await setTimeout(1_500);
let random = getRandomInt(faces) + 1;
random === 1 ? tails++ : heads++;
sum = sum + random;
const random = getRandomInt(faces) + 1;
if (random === 1) tails++;
else heads++;
sum += random;
message = message + `[ ${random} ] ${i === number - 1 ? "\n" : " "}`;
message += `[ ${random} ] ${i === number - 1 ? "\n" : " "}`;
await interaction.editReply(message);
}
if (number > 1 && faces > 2) {
await setTimeout(1_000);
message = message + subtext(`Soit au total : ${sum}`);
message += subtext(`Soit au total : ${sum}`);
}
if (number > 1 && faces === 2) {
await setTimeout(1_000);
message =
message +
subtext(
`Soit au total : ${sum}, ou bien ${tails} piles et ${heads} faces \n`
);
message += subtext(`Soit au total : ${sum}, ou bien ${tails} piles et ${heads} faces\n`);
}
await interaction.editReply(message);

View file

@ -1,13 +1,24 @@
import { MessageFlags, SlashCommandBuilder } from "discord.js";
import { shuffle } from "../../features/utilities.js";
// « Alice Bob » ou « Jean Pierre, Marie » : dès qu'il y a une virgule, seules les virgules
// séparent les joueurs.
function parsePlayers(input) {
const separator = input.includes(",") ? "," : /\s+/;
return input
.split(separator)
.map((player) => player.trim())
.filter(Boolean);
}
const command = {
data: new SlashCommandBuilder()
.setName("maketeam")
.setDescription("Crée des equipes au hasard")
.setDescription("Crée des équipes au hasard")
.addIntegerOption((option) =>
option
.setName("number")
.setDescription("Nombre d'équipe")
.setDescription("Nombre d'équipes")
.setMinValue(1)
.setMaxValue(20)
.setRequired(true)
@ -15,7 +26,7 @@ const command = {
.addStringOption((option) =>
option
.setName("players")
.setDescription("Liste des joueurs, séparés par un espace")
.setDescription("Joueurs séparés par des espaces, ou par des virgules si un nom contient un espace")
.setMinLength(1)
.setMaxLength(1000)
.setRequired(true)
@ -23,9 +34,9 @@ const command = {
async execute(interaction) {
const teamNumber = interaction.options.getInteger("number");
const players = interaction.options.getString("players");
const playersArray = players.trim().split(/\s+/);
const playersArray = parsePlayers(players);
if (teamNumber > playersArray.length) {
if (playersArray.length === 0 || teamNumber > playersArray.length) {
await interaction.reply({
content: "Le nombre d'équipes ne peut pas dépasser le nombre de joueurs.",
flags: MessageFlags.Ephemeral,
@ -34,30 +45,16 @@ const command = {
}
const teams = Array.from({ length: teamNumber }, () => []);
const shuffledPlayers = [...playersArray];
for (let index = shuffledPlayers.length - 1; index > 0; index--) {
const randomIndex = Math.floor(Math.random() * (index + 1));
[shuffledPlayers[index], shuffledPlayers[randomIndex]] = [
shuffledPlayers[randomIndex],
shuffledPlayers[index],
];
}
shuffledPlayers.forEach((player, index) => {
shuffle(playersArray).forEach((player, index) => {
const teamIndex = index % teamNumber;
teams[teamIndex].push(player);
});
let message = "";
let teamList = "";
teams.forEach((team, index) => {
teamList = `${teamList}\n${index + 1}. ${team.join(", ")}`;
});
message = `Yop ! Voici les équipes proposés :\n${teamList}`;
await interaction.reply(message);
const teamList = teams
.map((team, index) => `${index + 1}. ${team.join(", ")}`)
.join("\n");
await interaction.reply(`Yop ! Voici les équipes proposées :\n\n${teamList}`);
},
};
export { command };
export { command, parsePlayers };

View file

@ -4,7 +4,7 @@ import { requirePermission } from "../../features/permissions.js";
const command = {
data: new SlashCommandBuilder()
.setName("deletemsgs")
.setDescription("Supprime tous les messages, sauf ceux épinglés")
.setDescription("Supprime les 100 derniers messages, sauf ceux épinglés")
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
async execute(interaction) {
if (!(await requirePermission(interaction, PermissionFlagsBits.ManageMessages))) {
@ -23,9 +23,20 @@ const command = {
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
const fetched = await textChannel.messages.fetch({ limit: 100 });
const notPinned = fetched.filter((message) => !message.pinned);
// Discord refuse la suppression groupée des messages de plus de 14 jours : ils restent.
const deleted = await textChannel.bulkDelete(notPinned, true);
const tooOld = notPinned.size - deleted.size;
await interaction.editReply(`Et voilà, ${deleted.size} message(s) supprimé(s) ! 🐱`);
await interaction.editReply(
[
`Et voilà, ${deleted.size} message(s) supprimé(s) ! 🐱`,
tooOld > 0
? `${tooOld} message(s) de plus de 14 jours restent : Discord ne permet pas de les supprimer en lot.`
: null,
]
.filter(Boolean)
.join("\n")
);
},
};

View file

@ -1,33 +1,31 @@
import { MessageFlags, SlashCommandBuilder } from "discord.js";
// Liste construite à partir des commandes chargées : une commande ajoutée y apparaît d'office,
// avec sa description.
function buildCommandList(commands) {
const byCategory = new Map();
for (const command of commands) {
const lines = byCategory.get(command.category) ?? [];
lines.push(`\`/${command.data.name}\` : ${command.data.description}`);
byCategory.set(command.category, lines);
}
const sections = [...byCategory].map(
([category, lines]) => `__${category}__\n${lines.join("\n")}`
);
return `Voilà la liste des commandes que tu peux utiliser :\n\n${sections.join("\n\n")}`;
}
const command = {
data: new SlashCommandBuilder()
.setName("listcommand")
.setDescription("Affiche la liste des commandes disponibles"),
async execute(interaction) {
let message = `Voila la liste des commandes que tu peux utiliser :
__Categorie Utililaires__ :
\`/deletemsgs\`: Supprime les 100 derniers messages non épinglés
\`/invitation\`: Publie le message d'invitation temporaire (lien vérifié)
__Categorie Jukebox__ :
\`/play\`: Ajoute un morceau (fichier, lien direct ou morceau de la bibliothèque)
\`/skip\`: Passe au morceau suivant
\`/queue\`: Affiche la file d'attente
__Categorie Vocal__ :
\`/muteall\`: Rends tout le monde muet
\`/unmuteall\`: Rends la parole à tout le monde
\`/deafall\`: Rends tout le monde sourd
\`/undeafall\`: Rends l'ouïe à tout le monde
__Categorie Jeux__ :
\`/dice\`: Lance un ou plusieurs dés avec un nombre de faces choisi
\`/maketeam\`: Crée un certain nombre d'équipes en renseignant des joueurs (séparés par un espace)
`;
await interaction.reply({ content: message, flags: MessageFlags.Ephemeral });
await interaction.reply({
content: buildCommandList(interaction.client.commands.values()),
flags: MessageFlags.Ephemeral,
});
},
};
export { command };
export { buildCommandList, command };

View file

@ -3,7 +3,7 @@ import { MessageFlags, SlashCommandBuilder } from "discord.js";
const command = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Reponds avec Pong"),
.setDescription("Répond avec Pong"),
async execute(interaction) {
await interaction.reply({ content: "Euh... Pong ! 🐱", flags: MessageFlags.Ephemeral });
},

View file

@ -1,17 +1,17 @@
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
import { changeVoiceStatus } from "../../features/utilities.js";
import { changeVoiceStatus, commandVoiceChannel } from "../../features/utilities.js";
import { requirePermission } from "../../features/permissions.js";
const command = {
data: new SlashCommandBuilder()
.setName("deafall")
.setDescription("Deaf tout le monde dans le lounge")
.setDescription("Rend tout le monde sourd dans le salon vocal")
.setDefaultMemberPermissions(PermissionFlagsBits.DeafenMembers),
async execute(interaction) {
if (!(await requirePermission(interaction, PermissionFlagsBits.DeafenMembers))) return;
// Changer l'état de chaque membre peut dépasser les 3 s qu'accorde Discord pour répondre.
await interaction.deferReply();
await changeVoiceStatus(interaction.client, "deaf", "all");
await changeVoiceStatus(commandVoiceChannel(interaction), "deaf");
await interaction.editReply("On n'entends plus rien ! 🐱");
},
};

View file

@ -1,17 +1,17 @@
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
import { changeVoiceStatus } from "../../features/utilities.js";
import { changeVoiceStatus, commandVoiceChannel } from "../../features/utilities.js";
import { requirePermission } from "../../features/permissions.js";
const command = {
data: new SlashCommandBuilder()
.setName("muteall")
.setDescription("Mute tout le monde dans le lounge")
.setDescription("Rend tout le monde muet dans le salon vocal")
.setDefaultMemberPermissions(PermissionFlagsBits.MuteMembers),
async execute(interaction) {
if (!(await requirePermission(interaction, PermissionFlagsBits.MuteMembers))) return;
// Changer l'état de chaque membre peut dépasser les 3 s qu'accorde Discord pour répondre.
await interaction.deferReply();
await changeVoiceStatus(interaction.client, "mute", "all");
await changeVoiceStatus(commandVoiceChannel(interaction), "mute");
await interaction.editReply("Voila, tout le monde est mioute ! 🐱");
},
};

View file

@ -1,17 +1,17 @@
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
import { changeVoiceStatus } from "../../features/utilities.js";
import { changeVoiceStatus, commandVoiceChannel } from "../../features/utilities.js";
import { requirePermission } from "../../features/permissions.js";
const command = {
data: new SlashCommandBuilder()
.setName("undeafall")
.setDescription("Undeaf tout le monde dans le lounge")
.setDescription("Rend l'ouïe à tout le monde dans le salon vocal")
.setDefaultMemberPermissions(PermissionFlagsBits.DeafenMembers),
async execute(interaction) {
if (!(await requirePermission(interaction, PermissionFlagsBits.DeafenMembers))) return;
// Changer l'état de chaque membre peut dépasser les 3 s qu'accorde Discord pour répondre.
await interaction.deferReply();
await changeVoiceStatus(interaction.client, "undeaf", "all");
await changeVoiceStatus(commandVoiceChannel(interaction), "undeaf");
await interaction.editReply("Voila, les oreilles sont réparées ! 🐱");
},
};

View file

@ -1,17 +1,17 @@
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
import { changeVoiceStatus } from "../../features/utilities.js";
import { changeVoiceStatus, commandVoiceChannel } from "../../features/utilities.js";
import { requirePermission } from "../../features/permissions.js";
const command = {
data: new SlashCommandBuilder()
.setName("unmuteall")
.setDescription("Unmute tout le monde dans le lounge")
.setDescription("Rend la parole à tout le monde dans le salon vocal")
.setDefaultMemberPermissions(PermissionFlagsBits.MuteMembers),
async execute(interaction) {
if (!(await requirePermission(interaction, PermissionFlagsBits.MuteMembers))) return;
// Changer l'état de chaque membre peut dépasser les 3 s qu'accorde Discord pour répondre.
await interaction.deferReply();
await changeVoiceStatus(interaction.client, "unmute", "all");
await changeVoiceStatus(commandVoiceChannel(interaction), "unmute");
await interaction.editReply("Et.... unmioute ! 🐱");
},
};

View file

@ -1,7 +1,10 @@
// OWNER_USER_ID : la personne qui gère les serveurs de jeux (mentionnée dans leur message).
// Ancien nom, encore accepté : SHINUWA_USER_ID.
process.env.OWNER_USER_ID ||= process.env.SHINUWA_USER_ID;
const requiredVariables = [
"NODE_ENV",
"DISCORD_GUILD_ID",
"SHINUWA_USER_ID",
"OWNER_USER_ID",
"WEB_SERVER_PORT",
"WEB_API_KEY",
"DISCORD_APPLICATION_ID",
@ -76,9 +79,8 @@ if (notificationsApiKey && notificationsApiKey === process.env.WEB_API_KEY) {
}
const config = Object.freeze({
environnement: process.env.NODE_ENV,
discordGuildId: process.env.DISCORD_GUILD_ID,
shinuwaUserId: process.env.SHINUWA_USER_ID,
ownerUserId: process.env.OWNER_USER_ID,
webServerPort,
webApiKey: process.env.WEB_API_KEY,
webTrustedProxies,

View file

@ -6,7 +6,7 @@ const event = {
name: Events.InteractionCreate,
async execute(interaction) {
if (interaction.isAutocomplete()) {
const command = interaction.client.commands.get(interaction.commandName)?.command;
const command = interaction.client.commands.get(interaction.commandName);
try {
await command?.autocomplete?.(interaction);
} catch (error) {
@ -17,7 +17,7 @@ const event = {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName)?.command;
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(

View file

@ -12,11 +12,8 @@ const event = {
// File rechargée au démarrage : reprendre si quelqu'un est déjà dans le salon vocal.
client.musicQueue?.evaluateAloneStatus();
try {
await showGameServers(client);
} catch (error) {
console.error("Unable to initialize game server status", error);
}
// Les erreurs sont journalisées et retentées par showGameServers lui-même.
await showGameServers(client);
},
};

View file

@ -4,8 +4,14 @@ import { getJSONData } from "./utilities.js";
const PROBE_TIMEOUT = 3_000;
const REFRESH_INTERVAL = 120_000;
// Couleurs ANSI des blocs « ```ansi » de Discord. Échappements écrits en \u001b : un caractère
// ESC brut est invisible dans l'éditeur et a déjà disparu lors d'une modification.
const ONLINE = "\u001b[2;32mOnline\u001b[0m";
const OFFLINE = "\u001b[2;31mOffline\u001b[0m";
var currentStatus = [];
// Dernier message publié : on ne le réédite que si son contenu change (état d'un serveur,
// mais aussi serveur ajouté ou adresse modifiée dans la liste).
let publishedMessage = null;
// Essaie d'ouvrir une connexion TCP : vrai si le port répond dans le délai.
function probeTcp(host, port, { timeout = PROBE_TIMEOUT, connect = net.connect } = {}) {
@ -47,35 +53,29 @@ async function readServers(probe) {
return { ...data, servers };
}
async function checkServersStatus(client) {
const data = await readServers();
const newStatus = data.servers.map((server) => server.active);
function buildMessage(data) {
const servers = data.servers
.map(
(server) =>
"```ansi\n" +
`${server.game} : ${server.active ? ONLINE : OFFLINE}\n` +
`${server.address}\n` +
"```"
)
.join("");
if (JSON.stringify(newStatus) === JSON.stringify(currentStatus)) {
return;
}
await updateMessage(client, data);
currentStatus = newStatus;
return true;
return (
"Hello 😺 ! Voila les serveurs de jeux qu'on a chez nous :\n\n" +
servers +
`\nPour mettre en ligne un serveur, faut voir avec <@${config.ownerUserId}> , c'est lui qui gère ca !\n`
);
}
async function updateMessage(client, data) {
var newMessage = `Hello 😺 ! Voila les serveurs de jeux qu'on a chez nous :\n\n`;
data.servers.forEach((server) => {
newMessage =
newMessage +
"```ansi\n" +
`${server.game} : ` +
`${server.active ? "[2;32mOnline[0m" : "[2;31mOffline[0m"}\n` +
`${server.address}\n` +
"```";
});
newMessage =
newMessage +
`\nPour mettre en ligne un serveur, faut voir avec <@${config.shinuwaUserId}> , c'est lui qui gère ca !\n`;
async function refreshMessage(client) {
const content = buildMessage(await readServers());
if (content === publishedMessage) {
return false;
}
const channel = client.channels.cache.get(config.textChannelId);
if (!channel?.isTextBased()) {
@ -83,23 +83,23 @@ async function updateMessage(client, data) {
}
const message = await channel.messages.fetch(config.gameServersMessageId);
await message.edit(newMessage);
await message.edit(content);
publishedMessage = content;
console.log(
`[${new Date().toLocaleString()}] showGameServers: Game servers message updated`
);
return true;
}
async function showGameServers(client) {
const data = await readServers();
currentStatus = data.servers.map((server) => server.active);
await updateMessage(client, data);
const interval = setInterval(() => {
checkServersStatus(client).catch((error) =>
// Un échec (salon ou message introuvable, liste illisible) est journalisé et retenté au
// rafraîchissement suivant, y compris au démarrage.
function showGameServers(client) {
const refresh = () =>
refreshMessage(client).catch((error) =>
console.error("Unable to update game server status", error)
);
}, REFRESH_INTERVAL);
interval.unref();
setInterval(refresh, REFRESH_INTERVAL).unref();
return refresh();
}
export { probeTcp, serverStatus, showGameServers };
export { buildMessage, probeTcp, serverStatus, showGameServers };

View file

@ -1,59 +1,40 @@
import fs from "fs";
import fs from "node:fs";
import { config } from "../config.js";
async function changeVoiceStatus(client, status, members) {
const changeStatus = async (type, value, selectedMembers) => {
const operations = [];
switch (type) {
case "mute":
for (const member of selectedMembers.values()) {
operations.push(member.voice.setMute(value));
}
break;
case "deaf":
for (const member of selectedMembers.values()) {
operations.push(member.voice.setDeaf(value));
}
break;
}
// Un membre qui quitte le salon pendant l'opération ne doit pas faire échouer les autres.
const results = await Promise.allSettled(operations);
const failures = results.filter((result) => result.status === "rejected");
if (failures.length > 0) {
console.error(
`changeVoiceStatus: ${failures.length} member(s) could not be updated`,
failures[0].reason
);
}
};
const VOICE_ACTIONS = {
mute: (member) => member.voice.setMute(true),
unmute: (member) => member.voice.setMute(false),
deaf: (member) => member.voice.setDeaf(true),
undeaf: (member) => member.voice.setDeaf(false),
};
const voiceChannel = client.channels.cache.get(config.voiceChannelId);
if (!voiceChannel?.isVoiceBased()) {
// Salon vocal où se trouve la personne qui lance la commande, sinon celui de la configuration.
function commandVoiceChannel(interaction) {
const channel =
interaction.member?.voice?.channel ??
interaction.client.channels.cache.get(config.voiceChannelId);
if (!channel?.isVoiceBased()) {
throw new Error("Salon vocal configuré introuvable");
}
const connectedMembers = voiceChannel.members.filter(
(member) => !member.user.bot
);
return channel;
}
if (members === "all") {
members = connectedMembers;
// Applique l'action à tous les membres humains du salon.
async function changeVoiceStatus(channel, action) {
const apply = VOICE_ACTIONS[action];
if (!apply) {
throw new Error(`Statut vocal inconnu : ${action}`);
}
switch (status) {
case "mute":
await changeStatus("mute", true, members);
break;
case "unmute":
await changeStatus("mute", false, members);
break;
case "deaf":
await changeStatus("deaf", true, members);
break;
case "undeaf":
await changeStatus("deaf", false, members);
break;
default:
throw new Error(`Statut vocal inconnu : ${status}`);
const members = channel.members.filter((member) => !member.user.bot);
// Un membre qui quitte le salon pendant l'opération ne doit pas faire échouer les autres.
const results = await Promise.allSettled(members.map(apply));
const failures = results.filter((result) => result.status === "rejected");
if (failures.length > 0) {
console.error(
`changeVoiceStatus: ${failures.length} member(s) could not be updated`,
failures[0].reason
);
}
}
@ -68,8 +49,19 @@ function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
// Mélange de Fisher-Yates, sur place ; renvoie le tableau.
function shuffle(array) {
for (let index = array.length - 1; index > 0; index--) {
const randomIndex = getRandomInt(index + 1);
[array[index], array[randomIndex]] = [array[randomIndex], array[index]];
}
return array;
}
export {
changeVoiceStatus,
commandVoiceChannel,
getJSONData,
getRandomInt,
shuffle,
};

43
src/loadCommands.js Normal file
View file

@ -0,0 +1,43 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
const COMMANDS_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "commands");
// Nom affiché de chaque dossier de src/commands (catégorie de /listcommand).
const CATEGORY_LABELS = {
utility: "Utilitaires",
jukebox: "Jukebox",
vocal: "Vocal",
game: "Jeux",
};
// Charge les commandes de src/commands/<catégorie>/*.js. Chaque fichier exporte
// `command = { data, execute, autocomplete? }`.
async function loadCommands() {
const commands = [];
const folders = fs
.readdirSync(COMMANDS_DIR, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name)
.sort();
for (const folder of folders) {
const files = fs
.readdirSync(path.join(COMMANDS_DIR, folder))
.filter((file) => file.endsWith(".js"))
.sort();
for (const file of files) {
const filePath = path.join(COMMANDS_DIR, folder, file);
const { command } = await import(pathToFileURL(filePath).href);
if (!command?.data || typeof command.execute !== "function") {
console.warn(`[WARNING] The command at ${filePath} is missing "data" or "execute".`);
continue;
}
commands.push({ ...command, category: CATEGORY_LABELS[folder] ?? folder });
}
}
return commands;
}
export { loadCommands };

View file

@ -69,10 +69,6 @@ function invalidAudioError(cause) {
return error;
}
async function validateAudioFile(filePath) {
await probeAudioFile(filePath);
}
// Décode le fichier, normalise le volume et encode en Ogg Opus avec le ffmpeg natif : Discord
// reçoit l'Opus tel quel, sans réencodage en JavaScript. Fermer le flux arrête ffmpeg.
function createOpusStream(filePath, { spawnProcess = spawn } = {}) {
@ -131,4 +127,4 @@ function createOpusStream(filePath, { spawnProcess = spawn } = {}) {
return output;
}
export { LOUDNORM_FILTER, createOpusStream, probeAudioFile, validateAudioFile };
export { createOpusStream, probeAudioFile };

View file

@ -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

View file

@ -7,6 +7,7 @@ import {
updatePermanentTracks,
} from "../storage/storageManager.js";
import { serializeTrack, serializeTracks } from "../serializers.js";
import { shuffle } from "../../features/utilities.js";
function libraryRouter({ queue }) {
const router = Router();
@ -50,10 +51,7 @@ function libraryRouter({ queue }) {
router.post("/enqueue-all", (req, res) => {
const entries = getPermanentLibrary();
if (req.body?.shuffle === true) {
for (let index = entries.length - 1; index > 0; index--) {
const randomIndex = Math.floor(Math.random() * (index + 1));
[entries[index], entries[randomIndex]] = [entries[randomIndex], entries[index]];
}
shuffle(entries);
}
const tracks = entries.map((entry) =>

View file

@ -27,8 +27,8 @@ function queueRouter({ queue }) {
res.status(201).json({ track: serializeTrack(track) });
});
router.delete("/:trackId", async (req, res) => {
const removed = await queue.remove(req.params.trackId);
router.delete("/:trackId", (req, res) => {
const removed = queue.remove(req.params.trackId);
if (!removed) {
return res.status(404).json({ error: "Piste introuvable" });
}

View file

@ -173,7 +173,7 @@ function startWebServer(dependencies) {
.catch((error) => console.error("Unable to complete library metadata", error));
const app = createApp(dependencies);
const port = Number(process.env.PORT || config.webServerPort || 3000);
const port = config.webServerPort;
const server = app.listen(port, () => {
console.log(

View file

@ -12,20 +12,8 @@ const TEMP_FILE_MAX_AGE = 24 * 60 * 60 * 1000;
const MAX_LIBRARY_SIZE = 2 * 1024 * 1024 * 1024;
function ensureStorageLayout() {
if (!fs.existsSync(STORAGE_ROOT)) {
fs.mkdirSync(STORAGE_ROOT, { recursive: true });
}
if (!fs.existsSync(PERMANENT_DIR)) {
fs.mkdirSync(PERMANENT_DIR, { recursive: true });
}
if (!fs.existsSync(TEMP_DIR)) {
fs.mkdirSync(TEMP_DIR, { recursive: true });
}
if (!fs.existsSync(RUNTIME_DIR)) {
fs.mkdirSync(RUNTIME_DIR, { recursive: true });
for (const directory of [PERMANENT_DIR, TEMP_DIR, RUNTIME_DIR]) {
fs.mkdirSync(directory, { recursive: true });
}
if (!fs.existsSync(LIBRARY_FILE)) {
@ -117,7 +105,7 @@ function registerUploadedFile(
const extension = /^\.[a-z0-9]{1,10}$/.test(rawExtension)
? rawExtension
: "";
storedName = `${randomUUID()}${extension.toLowerCase()}`;
storedName = `${randomUUID()}${extension}`;
finalPath = path.join(PERMANENT_DIR, storedName);
fs.renameSync(file.path, finalPath);
permanentEntry = {
@ -219,7 +207,7 @@ function deleteFileSafe(filePath) {
}
try {
fs.existsSync(filePath) && fs.unlinkSync(filePath);
fs.rmSync(filePath, { force: true });
} catch (error) {
console.error(`Failed to delete file ${filePath}`, error);
}

View file

@ -1,6 +1,5 @@
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
const ENVIRONMENT = {
NODE_ENV: "test",
@ -16,30 +15,37 @@ const ENVIRONMENT = {
};
Object.assign(process.env, ENVIRONMENT);
async function loadCommands() {
const files = fs
.readdirSync("src/commands", { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.flatMap((directory) =>
fs
.readdirSync(`src/commands/${directory.name}`)
.filter((file) => file.endsWith(".js"))
.map((file) => `../src/commands/${directory.name}/${file}`)
);
return Promise.all(files.map((file) => import(file)));
}
const { loadCommands } = await import("../src/loadCommands.js");
test("all Discord commands expose valid command data", async () => {
const modules = await loadCommands();
assert.equal(modules.length, 13);
for (const module of modules) {
assert.doesNotThrow(() => module.command.data.toJSON());
assert.equal(typeof module.command.execute, "function");
const commands = await loadCommands();
assert.equal(commands.length, 13);
for (const command of commands) {
assert.doesNotThrow(() => command.data.toJSON());
assert.equal(typeof command.execute, "function");
assert.ok(command.category, command.data.name);
}
});
test("/listcommand lists every loaded command under its category", async () => {
const commands = await loadCommands();
const { buildCommandList } = await import("../src/commands/utility/listcommand.js");
const message = buildCommandList(commands);
for (const command of commands) {
assert.ok(message.includes(`\`/${command.data.name}\` : ${command.data.description}`));
}
assert.match(message, /__Jukebox__\n`\/play`/);
assert.ok(message.length <= 2000);
});
test("/maketeam splits players on commas when there are any", async () => {
const { parsePlayers } = await import("../src/commands/game/maketeam.js");
assert.deepEqual(parsePlayers(" Alice Bob\tChloé "), ["Alice", "Bob", "Chloé"]);
assert.deepEqual(parsePlayers("Jean Pierre, Marie,, Léo "), ["Jean Pierre", "Marie", "Léo"]);
});
test("administrative commands require Discord permissions", async () => {
const modules = await loadCommands();
const commands = await loadCommands();
const protectedCommands = new Set([
"deletemsgs",
"invitation",
@ -49,8 +55,8 @@ test("administrative commands require Discord permissions", async () => {
"undeafall",
]);
for (const module of modules) {
const data = module.command.data.toJSON();
for (const command of commands) {
const data = command.data.toJSON();
if (protectedCommands.has(data.name)) {
assert.notEqual(data.default_member_permissions, undefined, data.name);
assert.notEqual(data.default_member_permissions, null, data.name);
@ -67,3 +73,42 @@ test("/queue lists the current track and what comes next", async () => {
assert.match(message, /En cours : \*\*Thème \\\*principal\\\* \(3:07\)\*\*/);
assert.match(message, /1\. Suite \(1:05:09\)/);
});
test("vocal commands act on the caller's voice channel, skipping bots", async () => {
const { changeVoiceStatus, commandVoiceChannel } = await import("../src/features/utilities.js");
const { Collection } = await import("discord.js");
const muted = [];
const member = (id, { bot = false, fail = false } = {}) => ({
id,
user: { bot },
voice: {
setMute: async (value) => {
if (fail) throw new Error("left the channel");
muted.push([id, value]);
},
},
});
const callerChannel = {
isVoiceBased: () => true,
members: new Collection([
["a", member("a")],
["bot", member("bot", { bot: true })],
["gone", member("gone", { fail: true })],
["b", member("b")],
]),
};
const configuredChannel = { isVoiceBased: () => true, members: new Collection() };
const client = { channels: { cache: new Map([["1", configuredChannel]]) } };
assert.equal(commandVoiceChannel({ client, member: { voice: { channel: callerChannel } } }), callerChannel);
assert.equal(commandVoiceChannel({ client, member: { voice: { channel: null } } }), configuredChannel);
const originalError = console.error;
console.error = () => {};
try {
await changeVoiceStatus(callerChannel, "mute");
} finally {
console.error = originalError;
}
assert.deepEqual(muted, [["a", true], ["b", true]]);
});

View file

@ -15,7 +15,9 @@ Object.assign(process.env, {
GAME_SERVERS_MESSAGE_ID: "1",
});
const { probeTcp, serverStatus } = await import("../src/features/showGameServers.js");
const { buildMessage, probeTcp, serverStatus } = await import(
"../src/features/showGameServers.js"
);
test("a listening TCP port is online, a closed one offline", async () => {
const server = net.createServer((socket) => socket.end());
@ -44,3 +46,17 @@ test("checked servers are probed on checkPort, else on port", async () => {
assert.deepEqual(probed, ["games.example.com:25575", "games.example.com:25566"]);
assert.equal(await serverStatus({ address: "x", check: true }, probe), false);
});
test("the status message is coloured and mentions the owner", () => {
const message = buildMessage({
servers: [
{ game: "Minecraft", address: "games.example.com:25565", active: true },
{ game: "Palworld", address: "games.example.com:8211", active: false },
],
});
// Les couleurs des blocs ansi de Discord demandent le caractère ESC lui-même.
assert.ok(message.includes("Minecraft : \u001b[2;32mOnline\u001b[0m"));
assert.ok(message.includes("Palworld : \u001b[2;31mOffline\u001b[0m"));
// OWNER_USER_ID absent : l'ancien nom SHINUWA_USER_ID est encore accepté.
assert.match(message, /<@1>/);
});

View file

@ -152,7 +152,7 @@ test("removing the head of the queue while connecting plays the next track", asy
queue.enqueue(track("a"));
queue.enqueue(track("b"));
await queue.remove("a");
queue.remove("a");
release();
await settle();
@ -169,7 +169,7 @@ test("removing the current track returns it", async () => {
return true;
};
assert.equal((await queue.remove("a"))?.id, "a");
assert.equal((queue.remove("a"))?.id, "a");
queue.shutdown();
});