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.
57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
import { MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
|
||
import { ACCESS_LEVELS } from '../../config/constants.js';
|
||
import {
|
||
assertModerationTarget,
|
||
logModerationAction,
|
||
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('ban')
|
||
.setDescription('Bannir un membre')
|
||
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
|
||
.addUserOption((option) => option.setName('user').setDescription('Membre').setRequired(true))
|
||
.addStringOption((option) => option.setName('reason').setDescription('Motif').setMaxLength(500))
|
||
.addIntegerOption((option) =>
|
||
option
|
||
.setName('delete_days')
|
||
.setDescription('Supprimer aussi les messages des N derniers jours (0 à 7)')
|
||
.setMinValue(0)
|
||
.setMaxValue(7),
|
||
);
|
||
|
||
/** Bans the user, whether or not they are still on the server (M8-T04 / M8-T09). */
|
||
export async function execute(interaction) {
|
||
const user = interaction.options.getUser('user', true);
|
||
const reason = interaction.options.getString('reason');
|
||
const deleteDays = interaction.options.getInteger('delete_days') ?? 0;
|
||
|
||
const member = await interaction.guild.members.fetch(user.id).catch(() => null);
|
||
if (member) {
|
||
assertModerationTarget(interaction, member);
|
||
await member
|
||
.send({
|
||
embeds: [targetNoticeEmbed({ action: 'ban', guildName: interaction.guild.name, reason })],
|
||
})
|
||
.catch(() => {});
|
||
}
|
||
|
||
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
||
await interaction.guild.bans.create(user.id, {
|
||
reason: reason ?? `Bannissement demandé par ${interaction.user.tag}`,
|
||
deleteMessageSeconds: deleteDays * 86_400,
|
||
});
|
||
|
||
await logModerationAction(interaction, { action: 'ban', targetId: user.id, reason });
|
||
await interaction.editReply({
|
||
embeds: [
|
||
successEmbed(
|
||
`C’est fait : **${user.tag}** ne peut plus revenir sur le serveur. L’historique reste consultable avec \`/mod logs\`.`,
|
||
),
|
||
],
|
||
});
|
||
}
|