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:
BlackAngelTV committed 2026-09-25 20:29:19 +02:00
1 parent 859b229181
commit 99e1fd2723
9 files changed
+73 -27

No files matched your search

+4 -4
View File
@@ -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 },
);
+6 -4
View File
@@ -33,11 +33,13 @@ const DURATIONS = [
{ value: String(7 * 24 * 60 * 60_000), label: '7 jours' },
];
// Mirrors MODERATION_ACTIONS in `src/config/constants.js`, emoji included: the
// panel must not be the one place where a mute reads like a kick.
const MODERATION_ACTIONS = [
{ value: 'warn', label: 'Avertissement' },
{ value: 'mute', label: 'Exclusion temporaire' },
{ value: 'kick', label: 'Expulsion' },
{ value: 'ban', label: 'Bannissement' },
{ value: 'warn', label: '⚠️ Avertissement' },
{ value: 'mute', label: '🔇 Mise en sourdine' },
{ value: 'kick', label: '👢 Expulsion' },
{ value: 'ban', label: '🔨 Bannissement' },
];
async function moderate(member, reload) {
+1 -1
View File
@@ -230,7 +230,7 @@ export const VARIABLES = Object.freeze([
key: 'CHANNEL_MOD_LOGS_ID',
section: 'channels',
label: 'Salon des logs de modération',
help: 'Avertissements, exclusions, bannissements.',
help: 'Avertissements, mises en sourdine, bannissements.',
type: 'snowflake',
},
{