Members read all replies as one voice, so the wording now lives in one place:
the shared titles, the list marker and the "what to do next" hint come from
src/ui/embeds.js, and every module follows them.
An error explains the cause, recalls the rule and offers the way out instead of
blaming; a success says what happens next. Nothing agrees on the gender of a
person ("utilisateur", "cher/chère", "ravie"), which also keeps the sentences
shorter. Two tests lock the shared titles and reject gendered descriptions.
56 lines
2.2 KiB
JavaScript
56 lines
2.2 KiB
JavaScript
import { MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
|
|
import { ACCESS_LEVELS, COLORS, MODERATION_ACTIONS } from '../../config/constants.js';
|
|
import { listActions } from '../../database/repositories/moderation-repository.js';
|
|
import { formatDuration } from '../../services/moderation/moderation-service.js';
|
|
import { baseEmbed, infoEmbed } from '../../ui/embeds.js';
|
|
|
|
export const access = ACCESS_LEVELS.STAFF;
|
|
|
|
const HISTORY_LIMIT = 15;
|
|
|
|
export const data = new SlashCommandBuilder()
|
|
.setName('mod')
|
|
.setDescription('Outils de modération')
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers)
|
|
.addSubcommand((sub) =>
|
|
sub
|
|
.setName('logs')
|
|
.setDescription('Consulter les actions de modération')
|
|
.addUserOption((option) => option.setName('user').setDescription('Filtrer par membre')),
|
|
);
|
|
|
|
function formatEntry(row) {
|
|
const meta = MODERATION_ACTIONS[row.action];
|
|
const target = row.target_id ? `<@${row.target_id}>` : 'salon';
|
|
const duration = row.duration_ms ? ` pendant ${formatDuration(row.duration_ms)}` : '';
|
|
return (
|
|
`\`${row.created_at}\` **${meta?.label ?? row.action}** — ${target}${duration}\n` +
|
|
`↳ par <@${row.moderator_id}> · ${row.reason || 'sans motif'}`
|
|
);
|
|
}
|
|
|
|
/** Reads the moderation history from SQLite (M8-T06). */
|
|
export async function execute(interaction) {
|
|
const user = interaction.options.getUser('user');
|
|
const actions = listActions({
|
|
guildId: interaction.guildId,
|
|
targetId: user?.id ?? null,
|
|
limit: HISTORY_LIMIT,
|
|
});
|
|
|
|
const embed =
|
|
actions.length === 0
|
|
? infoEmbed(
|
|
'📜 Historique de modération',
|
|
user
|
|
? `Rien à signaler concernant ${user} : aucune action de modération enregistrée.`
|
|
: 'Aucune action de modération enregistrée sur ce serveur, tout est calme.',
|
|
)
|
|
: baseEmbed(COLORS.moderation)
|
|
.setTitle(user ? `📜 Historique de ${user.tag}` : '📜 Dernières actions de modération')
|
|
.setDescription(actions.map(formatEntry).join('\n\n'))
|
|
.setFooter({ text: `${actions.length} action(s) affichée(s)` });
|
|
|
|
await interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral });
|
|
}
|