fix(moderation): tell a mute apart from a kick in the logs
A timeout was filed as "Exclusion temporaire" right next to "Expulsion", so a sanction could not be read back from the log channel, the direct message or `/mod logs`. Each action now carries its own emoji and wording behind a single label, used by every surface.
This commit is contained in:
9 files changed
+73
-27
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { ChannelType, REST, Routes } from 'discord.js';
|
||||
import { ACCESS_LABELS, ACCESS_LEVELS, MODERATION_ACTIONS } from '../../config/constants.js';
|
||||
import { ACCESS_LABELS, ACCESS_LEVELS } from '../../config/constants.js';
|
||||
import { env } from '../../config/env.js';
|
||||
import { ExternalApiError } from '../../core/errors.js';
|
||||
import { createLogger } from '../../core/logger.js';
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
removeNotificationChannel,
|
||||
setNotificationChannel,
|
||||
} from '../../database/repositories/notification-repository.js';
|
||||
import { sendModerationLog } from '../../services/moderation/moderation-service.js';
|
||||
import { moderationLabel, sendModerationLog } from '../../services/moderation/moderation-service.js';
|
||||
import { badRequest, forbidden, notFound } from '../http.js';
|
||||
|
||||
/** Discord server management from the dashboard (M16-T05). */
|
||||
@@ -201,7 +201,7 @@ export function registerDiscordRoutes(router) {
|
||||
const reason = String(body.reason ?? '').trim() || 'Non précisé';
|
||||
const durationMs = action === 'mute' ? Number.parseInt(body.durationMs ?? 0, 10) : null;
|
||||
if (action === 'mute' && (!Number.isInteger(durationMs) || durationMs <= 0)) {
|
||||
throw badRequest('Une durée en millisecondes est requise pour une exclusion temporaire.');
|
||||
throw badRequest('Une durée en millisecondes est requise pour une mise en sourdine.');
|
||||
}
|
||||
|
||||
const audit = `${reason} — ${actor.displayName ?? actor.username} (tableau de bord)`;
|
||||
@@ -231,7 +231,7 @@ export function registerDiscordRoutes(router) {
|
||||
durationMs,
|
||||
});
|
||||
|
||||
return { ok: true, action, label: MODERATION_ACTIONS[action]?.label ?? action };
|
||||
return { ok: true, action, label: moderationLabel(action) };
|
||||
},
|
||||
{ access: ACCESS_LEVELS.STAFF },
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user