All checks were successful
Deploy Palico Bot / deploy (push) Successful in 32s
- Deploy workflow: pin node:24-bookworm; install openssh-client only if missing - Auth failure limiter counts only 401s (422/404 no longer lock out clients) - trust proxy configurable (WEB_TRUSTED_PROXIES), never "true" - DM route: loopback connections only, dedicated NOTIFICATIONS_API_KEY, 503 when unset - Jukebox: no polling without a key, stop on 401 - /invitation: posts the temporary invite message after checking the link - Stop tracking storage/library.json; README describes the real deployment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
|
|
const ENVIRONMENT = {
|
|
NODE_ENV: "test",
|
|
DISCORD_GUILD_ID: "1",
|
|
SHINUWA_USER_ID: "1",
|
|
WEB_SERVER_PORT: "3000",
|
|
WEB_API_KEY: "test-key",
|
|
DISCORD_APPLICATION_ID: "1",
|
|
DISCORD_TOKEN: "test-token",
|
|
VOICE_CHANNEL_ID: "1",
|
|
TEXT_CHANNEL_ID: "1",
|
|
GAME_SERVERS_MESSAGE_ID: "1",
|
|
};
|
|
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)));
|
|
}
|
|
|
|
test("all Discord commands expose valid command data", async () => {
|
|
const modules = await loadCommands();
|
|
assert.equal(modules.length, 10);
|
|
for (const module of modules) {
|
|
assert.doesNotThrow(() => module.command.data.toJSON());
|
|
assert.equal(typeof module.command.execute, "function");
|
|
}
|
|
});
|
|
|
|
test("administrative commands require Discord permissions", async () => {
|
|
const modules = await loadCommands();
|
|
const protectedCommands = new Set([
|
|
"deletemsgs",
|
|
"invitation",
|
|
"muteall",
|
|
"unmuteall",
|
|
"deafall",
|
|
"undeafall",
|
|
]);
|
|
|
|
for (const module of modules) {
|
|
const data = module.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);
|
|
}
|
|
}
|
|
});
|