diff --git a/src/features/perfsweep.js b/src/features/perfsweep.js index 5876f86..d34c46e 100644 --- a/src/features/perfsweep.js +++ b/src/features/perfsweep.js @@ -4,6 +4,8 @@ import { LINKS } from '../config.js'; export const EVERY_MS = 5 * 60_000; +// No slash command: bot.js maps every feature's `commands`, so a missing list crashed Kira at start. +export const commands = []; // Returns how many captures the site deleted, or null when no token is set. export async function sweep({ token = process.env.PERF_SWEEP_TOKEN, fetchImpl = fetch } = {}) { diff --git a/test/perfsweep.test.js b/test/perfsweep.test.js index ffcddd3..db4f99e 100644 --- a/test/perfsweep.test.js +++ b/test/perfsweep.test.js @@ -13,3 +13,14 @@ test('the sweep posts to the site with the token, and does nothing without one', assert.equal(calls[0].options.headers.Authorization, 'Bearer s3cret'); await assert.rejects(sweep({ token: 's3cret', fetchImpl: async () => ({ ok: false, status: 403 }) }), /HTTP 403/); }); + +test('every feature bot.js loads exports a commands list (a missing one crashed Kira at start)', async () => { + const src = (await import('node:fs')).readFileSync(new URL('../src/bot.js', import.meta.url), 'utf8'); + const list = src.match(/const FEATURES = \[([^\]]+)\]/)[1].split(',').map((s) => s.trim()); + for (const name of list) { + const file = src.match(new RegExp(`import \\* as ${name} from '\\./features/([\\w-]+)\\.js'`))?.[1]; + if (!file) continue; + const m = await import(`../src/features/${file}.js`); + assert.ok(Array.isArray(m.commands), `${file}.js exports no commands array`); + } +});