feat(settings): make the server settings real, and widen them

The dashboard offered seven switches that nothing read: they promised a
behaviour the bot did not have, which is worse than offering nothing.

Every setting is now declared once, with its type, its bounds and its
explanation, and the services read it: the welcome message and its wording,
the automatic role, departure notices, the private notice sent to a
sanctioned member, the default mute duration, how much history a ban erases,
whether a closed ticket is deleted or archived, and an optional role mention
on the Gitea notifications.

A test walks the sources and fails when a declared key is read nowhere, so
the list cannot drift back into decoration.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
nocodeandClaude Opus 5 committed 2026-09-23 23:20:05 +02:00
1 parent d439b1b3e8
commit 406b5af3ea
13 files changed
+576 -146

No files matched your search

@@ -1,5 +1,6 @@
import { COLORS, MODERATION_ACTIONS } from '../../config/constants.js';
import { env } from '../../config/env.js';
import { readSetting } from '../../config/guild-settings.js';
import { UserFacingError } from '../../core/errors.js';
import { canActOn } from '../../core/permissions.js';
import { logEvent } from '../../database/repositories/event-log-repository.js';
@@ -95,6 +96,19 @@ export async function sendModerationLog(
await channel.send({ embeds: [embed] }).catch(() => {});
}
/**
* Sends the private notice to the sanctioned member, when the server wants one
* (M8-T07). Never throws: plenty of accounts refuse direct messages, and that
* must not turn a successful sanction into an error.
*/
export async function notifyTarget(member, payload) {
if (!readSetting('moderation.dmTarget', member.guild.id)) return false;
return member
.send(payload)
.then(() => true)
.catch(() => false);
}
/** Direct message sent to the member who is being moderated (M8-T07). */
export function targetNoticeEmbed({ action, guildName, reason = null, durationMs = null }) {
const meta = MODERATION_ACTIONS[action];