Consolidate module system before module development - #212
Conversation
|
Review clanker : Pas mergeable en l-etat, pour raisons process + conflits :
Cause racine : la branche est basee sur d0c40fe et origin/master a ~19 commits d-avance, dont du fonctionnel qui touche les memes fichiers. Un rebase sur origin/master est requis, avec au moins ces resolutions :
Deux remarques design pour le rebase :
Cote ordre de merge avec #217 (zones differentes, auto-merge probable dans les deux sens), je recommande de faire passer celle-ci d-abord puisque c-est la fondation annoncee. Process suggere : rebase -> pnpm build && pnpm test -> sortir du draft -> review. Je ne merge donc pas. |
3006243 to
780fb44
Compare
|
Rebase done, PR is now ready and all green. Summary of what changed since the review:
Verified locally: tsc clean, oxlint clean, 180/180 tests pass. CI is green too (lint, build, docker, CodeQL). Remaining step: 1 approving review is still required by the master branch policy (auto-merge is enabled, so the PR will merge automatically once approved). Note the pre-existing oxfmt drift across the repo (142 files fail oxfmt --check even on master) — I only formatted the 3 files touched here so the diff stays minimal. |
Add a global core guildCreate listener: explicit config init on first join, reinstall of enabled modules guild commands on rejoin (Discord purges them on kick), and a Components V2 welcome message in the system channel with owner DM fallback. Nothing is deleted on leave so a rejoin restores history. updateModuleActivation is now an upsert. Co-Authored-By: Claude Code <noreply@anthropic.com>
Rethrow Discord failures from install/uninstall so the DB state only
flips on success; skip the activatedVersion bump on failed updates so
they retry next boot. Tolerate missing activatedVersion (""/null) as
0.0.0 instead of throwing. Resync downgraded guilds instead of leaving
them behind. Fetch dev-guild module states in parallel and share one
bulk-PUT helper between the dev and prod paths.
Co-Authored-By: Claude Code <noreply@anthropic.com>
A throwing onInstall/onUninstall no longer leaves the guild marked enabled/disabled, which used to deadlock the next install with "already installed". Co-Authored-By: Claude Code <noreply@anthropic.com>
References to deleted channels/roles/users deserialized to null and crashed consumers (e.g. channel.id). Lists now filter them out with a structured warning instead of console.warn. Co-Authored-By: Claude Code <noreply@anthropic.com>
The old heuristic could return a member user id or a whole event object as guildId. Only real string ids resolve now; guild-less events run without config. Co-Authored-By: Claude Code <noreply@anthropic.com>
Autocomplete now receives the command module config instead of the core one. Command execution is wrapped in try/catch with an ephemeral error reply (followUp when already answered) and guild-less interactions are ignored. New requiresAdmin flag on commands, enforced centrally and set on both core commands. Duplicate interaction customIds warn at dispatch; rejected interaction checks log at debug. Co-Authored-By: Claude Code <noreply@anthropic.com>
A broken module import or a throwing onLoad no longer aborts the whole boot: the module is skipped with an error log. onLoad supports async and all three lifecycle hooks are optional, dropping the log-only boilerplate from the example modules. Co-Authored-By: Claude Code <noreply@anthropic.com>
Also drops the declared-but-never-propagated configType field from event listeners. Co-Authored-By: Claude Code <noreply@anthropic.com>
New #lib/testing.js: makeTestConfig, fakeGuild/fakeChannel/fakeMessage, initTestI18n and silenceLogs, so module tests stop reinventing mocks (and stop accidentally booting the bot). The guild-create listener test is migrated onto them as proof. Co-Authored-By: Claude Code <noreply@anthropic.com>
validate-env-vars runs under tsx so it imports the single dev-mode definition from #lib/env.js instead of duplicating the development literal. dev/start scripts updated to match. Co-Authored-By: Claude Code <noreply@anthropic.com>
Generates a compiling, tested module skeleton (definition, config schema, namespaced example command, guarded example listener, en/fr i18n, commented Prisma model, test on the shared helpers). Co-Authored-By: Claude Code <noreply@anthropic.com>
The consolidator now reports the model and both files instead of failing late at generate time. Covered by a unit test; scripts tests join the unit project. Co-Authored-By: Claude Code <noreply@anthropic.com>
LOG_LEVEL accepts fatal/error/warn/info/debug/trace/silent and falls back to debug otherwise. Documented in AGENTS.md. Co-Authored-By: Claude Code <noreply@anthropic.com>
Document pnpm new-module and the shared test helpers, plus a pre-production checklist (version bump, prefixed names, DM guards, requiresAdmin, prisma order). Co-Authored-By: Claude Code <noreply@anthropic.com>
780fb44 to
7f9198f
Compare
Consolidates the existing module system (core + lib + tooling + docs) before new module development (e.g. Autopin). Stacked per-feature commits, all green (tsc, 144 unit, 36 integration).
Silent killers fixed
activatedVersiontolerated instead of throwing; downgrades resyncBoot resilience
onLoadskip the module instead of aborting boot;onLoadsupports asyncAuthor tooling
#lib/testing.js) +pnpm new-modulescaffold (verified end to end)requiresAdminon commands, duplicatecustomIdrejection, publishing checklist,LOG_LEVEL, TS env validator with one shared dev constant🤖 Generated with Claude Code