Compare commits
No commits in common. "be21ca36c236a87bab019546446918113c8d6d64" and "2298cff2fa66dd6eecb1d80f2272738bc0ce0e58" have entirely different histories.
be21ca36c2
...
2298cff2fa
5 changed files with 2 additions and 71 deletions
|
|
@ -1,13 +1,5 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
# v0.8.5
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
- The Discord bot answers commands again. Yesterday's release-notes update carried an over-long option description that crashed the bot at startup, silencing every command.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# v0.8.4
|
# v0.8.4
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "polaris-task-force",
|
"name": "polaris-task-force",
|
||||||
"version": "0.8.5",
|
"version": "0.8.4",
|
||||||
"description": "Web app for the Arma 3 unit Polaris Task Force. Uses Next.js for client- and server-side rendering, with a Postgres database and some other neat libraries.",
|
"description": "Web app for the Arma 3 unit Polaris Task Force. Uses Next.js for client- and server-side rendering, with a Postgres database and some other neat libraries.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ export const changelogCommand: BotCommand = {
|
||||||
option
|
option
|
||||||
.setName("range")
|
.setName("range")
|
||||||
.setDescription(
|
.setDescription(
|
||||||
"Version or range: v0.4.0, v0.3.0..v0.5.0, open ends (v0.3.0.., ..v0.5.0). Omit for latest.",
|
"Version or range: v0.4.0 (single), v0.3.0..v0.5.0 (inclusive), v0.3.0.. (to latest), ..v0.5.0 (from oldest). Omit for the latest entry.",
|
||||||
),
|
),
|
||||||
) as SlashCommandBuilder,
|
) as SlashCommandBuilder,
|
||||||
execute: async (interaction, payload) => {
|
execute: async (interaction, payload) => {
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,4 @@ export const commands: BotCommand[] = [
|
||||||
announceCommand,
|
announceCommand,
|
||||||
changelogCommand,
|
changelogCommand,
|
||||||
remindEvaluationsCommand,
|
remindEvaluationsCommand,
|
||||||
rollCallCommand,
|
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
import fs from "fs";
|
|
||||||
import path from "path";
|
|
||||||
import { describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Slash command builders validate Discord's constraints (name format,
|
|
||||||
* description <= 100 chars, option counts) at construction time, so a single
|
|
||||||
* over-long description crashes the whole bot process at import before it can
|
|
||||||
* log in - taking every command down, not just the offending one. This test
|
|
||||||
* imports the command registry and serializes every builder so CI catches
|
|
||||||
* that class of failure instead of the prod crash loop doing it.
|
|
||||||
*/
|
|
||||||
describe("Bot slash command builders", () => {
|
|
||||||
// config.ts fail-fasts on missing env at import; supply dummies (no
|
|
||||||
// network happens here, toJSON is pure).
|
|
||||||
process.env.DISCORD_TOKEN ||= "regression-test-token";
|
|
||||||
process.env.DISCORD_GUILD_ID ||= "123456789012345678";
|
|
||||||
|
|
||||||
it("import and serialize within Discord's builder constraints", async () => {
|
|
||||||
const { commands } = await import("@/bot/commands");
|
|
||||||
expect(commands.length).toBeGreaterThan(0);
|
|
||||||
|
|
||||||
for (const command of commands) {
|
|
||||||
const json = command.builder.toJSON();
|
|
||||||
expect(json.name).toBeTruthy();
|
|
||||||
expect((json.description ?? "").length).toBeLessThanOrEqual(100);
|
|
||||||
for (const option of json.options ?? []) {
|
|
||||||
expect(
|
|
||||||
(option.description ?? "").length,
|
|
||||||
`option "${option.name}" on /${json.name}`,
|
|
||||||
).toBeLessThanOrEqual(100);
|
|
||||||
}
|
|
||||||
expect(() => command.builder.toJSON()).not.toThrow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("registers every BotCommand exported by a file in commands/", async () => {
|
|
||||||
const dir = path.join(process.cwd(), "src", "bot", "commands");
|
|
||||||
const { commands } = await import("@/bot/commands");
|
|
||||||
const registered = new Set(commands.map((c) => c.builder.name));
|
|
||||||
|
|
||||||
const files = fs
|
|
||||||
.readdirSync(dir)
|
|
||||||
.filter((file) => file.endsWith(".ts") && file !== "index.ts");
|
|
||||||
expect(files.length).toBeGreaterThanOrEqual(7);
|
|
||||||
|
|
||||||
for (const file of files) {
|
|
||||||
const mod = (await import(path.join(dir, file))) as Record<string, unknown>;
|
|
||||||
for (const value of Object.values(mod)) {
|
|
||||||
const candidate = value as { builder?: { name?: string }; execute?: unknown };
|
|
||||||
if (candidate && typeof candidate === "object" && candidate.builder?.name && candidate.execute) {
|
|
||||||
expect(
|
|
||||||
registered.has(candidate.builder.name),
|
|
||||||
`/${candidate.builder.name} (${file}) is not in the commands registry`,
|
|
||||||
).toBe(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Reference in a new issue