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>
53 lines
2.0 KiB
JavaScript
53 lines
2.0 KiB
JavaScript
import { MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
|
||
import { ACCESS_LEVELS } from '../../config/constants.js';
|
||
import { countActions } from '../../database/repositories/moderation-repository.js';
|
||
import {
|
||
assertModerationTarget,
|
||
fetchTargetMember,
|
||
logModerationAction,
|
||
notifyTarget,
|
||
targetNoticeEmbed,
|
||
} from '../../services/moderation/moderation-service.js';
|
||
import { successEmbed } from '../../ui/embeds.js';
|
||
|
||
export const access = ACCESS_LEVELS.STAFF;
|
||
|
||
export const data = new SlashCommandBuilder()
|
||
.setName('warn')
|
||
.setDescription('Avertir un membre')
|
||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers)
|
||
.addUserOption((option) => option.setName('user').setDescription('Membre').setRequired(true))
|
||
.addStringOption((option) =>
|
||
option.setName('reason').setDescription('Motif').setRequired(true).setMaxLength(500),
|
||
);
|
||
|
||
/** Records the warning, notifies the member and logs it (M8-T01 / M8-T06). */
|
||
export async function execute(interaction) {
|
||
const user = interaction.options.getUser('user', true);
|
||
const reason = interaction.options.getString('reason', true);
|
||
|
||
const target = await fetchTargetMember(interaction, user.id);
|
||
assertModerationTarget(interaction, target);
|
||
|
||
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
||
await logModerationAction(interaction, { action: 'warn', targetId: target.id, reason });
|
||
|
||
const total = countActions({ guildId: interaction.guildId, targetId: target.id, action: 'warn' });
|
||
await notifyTarget(target, {
|
||
embeds: [
|
||
targetNoticeEmbed({ action: 'warn', guildName: interaction.guild.name, reason }).addFields({
|
||
name: 'Avertissements',
|
||
value: String(total),
|
||
}),
|
||
],
|
||
});
|
||
|
||
await interaction.editReply({
|
||
embeds: [
|
||
successEmbed(
|
||
`C’est fait : **${target.user.tag}** reçoit un avertissement (${total} au total). La personne a aussi reçu un message privé quand c’était possible.`,
|
||
),
|
||
],
|
||
});
|
||
}
|