diff --git a/src/commands/community/fun.js b/src/commands/community/fun.js index 9bc5337..3423d42 100644 --- a/src/commands/community/fun.js +++ b/src/commands/community/fun.js @@ -1,7 +1,7 @@ import { SlashCommandBuilder } from 'discord.js'; import { ACCESS_LEVELS, COLORS } from '../../config/constants.js'; import { parseChoices } from '../../services/polls/poll-service.js'; -import { baseEmbed } from '../../ui/embeds.js'; +import { baseEmbed, bullets } from '../../ui/embeds.js'; export const access = ACCESS_LEVELS.USER; @@ -62,7 +62,7 @@ export async function execute(interaction) { if (subcommand === 'coinflip') { const result = pick(['Pile', 'Face']); await interaction.reply({ - embeds: [baseEmbed(COLORS.info).setTitle('Pile ou face').setDescription(`đŸȘ™ ${result} !`)], + embeds: [baseEmbed(COLORS.info).setTitle('đŸȘ™ Pile ou face').setDescription(`**${result}** !`)], }); return; } @@ -73,8 +73,8 @@ export async function execute(interaction) { await interaction.reply({ embeds: [ baseEmbed(COLORS.info) - .setTitle(`Lancer de dĂ© (d${sides})`) - .setDescription(`đŸŽČ Tu obtiens **${roll}** !`), + .setTitle(`đŸŽČ Lancer de dĂ© (d${sides})`) + .setDescription(`Tu obtiens **${roll}** !`), ], }); return; @@ -99,8 +99,8 @@ export async function execute(interaction) { await interaction.reply({ embeds: [ baseEmbed(COLORS.info) - .setTitle('Choix alĂ©atoire') - .addFields({ name: 'Options', value: options.map((option) => `‱ ${option}`).join('\n') }) + .setTitle('🎯 Choix alĂ©atoire') + .addFields({ name: 'Options', value: bullets(options) }) .setDescription(`Je choisis : **${pick(options)}**`), ], }); diff --git a/src/commands/community/poll.js b/src/commands/community/poll.js index 17e6800..53c6aae 100644 --- a/src/commands/community/poll.js +++ b/src/commands/community/poll.js @@ -13,20 +13,29 @@ export const data = new SlashCommandBuilder() .setName('create') .setDescription('CrĂ©er un sondage') .addStringOption((option) => - option.setName('question').setDescription('Question').setRequired(true).setMaxLength(200), + option.setName('question').setDescription('Question posĂ©e').setRequired(true).setMaxLength(200), ) .addStringOption((option) => - option.setName('choices').setDescription('Choix sĂ©parĂ©s par ";" (2 Ă  10)').setRequired(true), + option + .setName('choices') + .setDescription('Propositions sĂ©parĂ©es par des « ; » (2 Ă  10)') + .setRequired(true), ) .addIntegerOption((option) => - option.setName('minutes').setDescription('DurĂ©e en minutes').setMinValue(1).setMaxValue(10_080), + option + .setName('minutes') + .setDescription('DurĂ©e avant fermeture automatique, en minutes') + .setMinValue(1) + .setMaxValue(10_080), ), ) .addSubcommand((sub) => sub .setName('close') .setDescription('Fermer un sondage') - .addIntegerOption((option) => option.setName('id').setDescription('ID du sondage').setRequired(true)), + .addIntegerOption((option) => + option.setName('id').setDescription('NumĂ©ro du sondage (affichĂ© dans l’embed)').setRequired(true), + ), ); /** Polls are published in the current channel and voted with buttons (M10). */ @@ -44,6 +53,10 @@ export async function execute(interaction) { await interaction.deferReply({ flags: MessageFlags.Ephemeral }); const pollId = await createPoll(interaction, { question, choicesInput, minutes }); await interaction.editReply({ - embeds: [successEmbed(`Sondage **#${pollId}** publiĂ© dans <#${interaction.channelId}>.`)], + embeds: [ + successEmbed( + `Ton sondage **#${pollId}** est en ligne dans <#${interaction.channelId}> : tout le monde vote avec les boutons.`, + ), + ], }); } diff --git a/src/commands/community/stats.js b/src/commands/community/stats.js index 75bc98a..a8ac0d8 100644 --- a/src/commands/community/stats.js +++ b/src/commands/community/stats.js @@ -21,7 +21,7 @@ export const data = new SlashCommandBuilder() const discordStatsEmbed = (interaction) => { const guild = interaction.guild; return baseEmbed() - .setTitle(`Statistiques — ${guild.name}`) + .setTitle(`📊 Statistiques — ${guild.name}`) .setThumbnail(guild.iconURL({ size: 128 })) .addFields( { name: 'Membres', value: String(guild.memberCount), inline: true }, @@ -48,9 +48,9 @@ async function giteaStatsEmbed() { const release = asList(releases)[0]; const embed = baseEmbed(COLORS.gitea) - .setTitle('ActivitĂ© Gitea') + .setTitle('📈 ActivitĂ© Gitea') .setURL(repositoryUrl()) - .setDescription(latestCommits || 'Aucun commit rĂ©cent.') + .setDescription(latestCommits || 'Aucun commit rĂ©cent pour le moment.') .addFields( { name: 'Issues ouvertes', value: String(asList(issues).length), inline: true }, { name: 'PR ouvertes', value: String(asList(pulls).length), inline: true }, @@ -67,7 +67,7 @@ function fwsStatsEmbed(interaction) { const total = actions.reduce((sum, row) => sum + row.count, 0); return baseEmbed(COLORS.gitea) - .setTitle('Indicateurs FWS') + .setTitle('📈 Indicateurs FWS') .addFields( { name: 'Tickets ouverts', value: String(countOpenTickets(interaction.guildId)), inline: true }, { name: 'Sondages créés', value: String(countPolls(interaction.guildId)), inline: true }, @@ -107,7 +107,9 @@ export async function execute(interaction) { log.error('Could not read Gitea stats', error); await interaction.editReply({ embeds: [ - errorEmbed('Les statistiques Gitea sont indisponibles. VĂ©rifie `GITEA_URL` et `GITEA_TOKEN`.'), + errorEmbed( + 'Les statistiques Gitea ne rĂ©pondent pas. RĂ©essaie dans un instant — si ça continue, l’équipe peut vĂ©rifier `GITEA_URL` et `GITEA_TOKEN`. Le reste du bot fonctionne normalement.', + ), ], }); } diff --git a/src/commands/fws/fws.js b/src/commands/fws/fws.js index 172802d..19e612e 100644 --- a/src/commands/fws/fws.js +++ b/src/commands/fws/fws.js @@ -24,8 +24,10 @@ export const data = new SlashCommandBuilder() .addSubcommand((sub) => sub .setName('changelog') - .setDescription("Changements d'une version") - .addStringOption((option) => option.setName('version').setDescription('Version (derniĂšre par dĂ©faut)')), + .setDescription('NouveautĂ©s d’une version') + .addStringOption((option) => + option.setName('version').setDescription('Version souhaitĂ©e (la derniĂšre par dĂ©faut)'), + ), ); const officialLinks = () => [ @@ -62,7 +64,7 @@ async function showInfo(interaction) { const configured = readSetting(interaction.guildId, 'fws.info', DEFAULT_PRESENTATION); const description = typeof configured === 'string' && configured ? configured : DEFAULT_PRESENTATION; await interaction.reply({ - embeds: [baseEmbed().setTitle('FWS & FWS Arch').setDescription(description)], + embeds: [baseEmbed().setTitle('🚀 FWS & FWS Arch').setDescription(description)], components: linkButtons(officialLinks()), }); } @@ -73,8 +75,10 @@ async function showVersion(interaction) { await interaction.reply({ embeds: [ fallback - ? infoEmbed('Version FWS Arch', `Version publiĂ©e : **${fallback}**`) - : errorEmbed('Gitea n’est pas configurĂ© : impossible de lire la derniĂšre version.'), + ? infoEmbed('📩 Version FWS Arch', `DerniĂšre version publiĂ©e : **${fallback}**`) + : errorEmbed( + 'La partie Gitea n’est pas encore configurĂ©e : je ne peux pas lire la derniĂšre version. L’équipe peut la renseigner dans le `.env`.', + ), ], }); return; @@ -87,8 +91,8 @@ async function showVersion(interaction) { await interaction.editReply({ embeds: [ fallback - ? infoEmbed('Version FWS Arch', `Version publiĂ©e : **${fallback}**`) - : infoEmbed('Version FWS Arch', 'Aucune release publiĂ©e pour le moment.'), + ? infoEmbed('📩 Version FWS Arch', `DerniĂšre version publiĂ©e : **${fallback}**`) + : infoEmbed('📩 Version FWS Arch', 'Aucune release publiĂ©e pour le moment.'), ], }); return; @@ -123,15 +127,15 @@ async function showStatus(interaction) { const uptime = Math.floor(process.uptime()); const embed = baseEmbed(COLORS.info) - .setTitle('État des services') + .setTitle('đŸ©ș État des services') .addFields( { name: 'API Gitea', value: !giteaConfigured - ? '⚙ Non configurĂ©e' + ? '⚙ Pas encore configurĂ©e' : giteaReachable ? `✅ En ligne — ${repositoryUrl()}` - : '❌ Injoignable', + : '❌ Injoignable pour le moment', inline: false, }, { @@ -142,7 +146,9 @@ async function showStatus(interaction) { { name: 'Base SQLite', value: - openTickets === null ? '❌ Indisponible' : `✅ Accessible — ${openTickets} ticket(s) ouvert(s)`, + openTickets === null + ? '❌ Indisponible pour le moment' + : `✅ Accessible — ${openTickets} ticket(s) ouvert(s)`, inline: false, }, { @@ -150,7 +156,7 @@ async function showStatus(interaction) { value: `✅ ConnectĂ© — ${Math.round(interaction.client.ws.ping)} ms`, inline: false, }, - { name: 'DisponibilitĂ© du bot', value: `` }, + { name: 'En ligne depuis', value: `` }, ); await interaction.editReply({ embeds: [embed] }); @@ -160,7 +166,11 @@ async function showChangelog(interaction) { const version = interaction.options.getString('version'); if (!isGiteaConfigured()) { await interaction.reply({ - embeds: [errorEmbed('Gitea n’est pas configurĂ© : le changelog est indisponible.')], + embeds: [ + errorEmbed( + 'La partie Gitea n’est pas encore configurĂ©e : le changelog arrivera dĂšs qu’elle sera branchĂ©e.', + ), + ], }); return; } @@ -170,7 +180,12 @@ async function showChangelog(interaction) { const release = version ? await gitea.getReleaseByTag(version) : await latestRelease(); if (!release) { await interaction.editReply({ - embeds: [infoEmbed('Changelog', `Aucune release trouvĂ©e pour **${version}**.`)], + embeds: [ + infoEmbed( + '📜 Changelog', + `Je ne trouve aucune release pour **${version}** : \`/gitea release\` liste les versions existantes.`, + ), + ], }); return; } @@ -183,7 +198,12 @@ async function showChangelog(interaction) { if (version) { log.warn(`Release ${version} not found`, error); await interaction.editReply({ - embeds: [infoEmbed('Changelog', `La version **${version}** n’existe pas dans les releases Gitea.`)], + embeds: [ + infoEmbed( + '📜 Changelog', + `Cette version **${version}** n’existe pas dans les releases Gitea : \`/gitea release\` liste celles qui existent.`, + ), + ], }); return; } @@ -199,7 +219,7 @@ export async function execute(interaction) { return; case 'links': await interaction.reply({ - embeds: [baseEmbed().setTitle('Liens officiels FWS')], + embeds: [baseEmbed().setTitle('🔗 Liens officiels FWS')], components: linkButtons(officialLinks()), }); return; diff --git a/src/commands/general/help.js b/src/commands/general/help.js index f62f16d..889b3fd 100644 --- a/src/commands/general/help.js +++ b/src/commands/general/help.js @@ -1,7 +1,7 @@ import { MessageFlags, SlashCommandBuilder } from 'discord.js'; -import { ACCESS_LEVELS } from '../../config/constants.js'; +import { ACCESS_LABELS, ACCESS_LEVELS } from '../../config/constants.js'; import { getAccessLevel } from '../../core/permissions.js'; -import { baseEmbed } from '../../ui/embeds.js'; +import { baseEmbed, bullets } from '../../ui/embeds.js'; export const access = ACCESS_LEVELS.USER; @@ -16,6 +16,10 @@ export async function execute(interaction) { .map((command) => `\`/${command.data.name}\` — ${command.data.description}`) .sort(); - const embed = baseEmbed().setTitle('Commandes FWS-Bot').setDescription(lines.join('\n')); + const embed = baseEmbed() + .setTitle('đŸ€– Tes commandes') + .setDescription( + `Tu es au niveau **${ACCESS_LABELS[level]}**. Voici ce que tu peux lancer :\n\n${bullets(lines)}`, + ); await interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral }); } diff --git a/src/commands/gitea/gitea.js b/src/commands/gitea/gitea.js index bb86657..99d035f 100644 --- a/src/commands/gitea/gitea.js +++ b/src/commands/gitea/gitea.js @@ -2,7 +2,7 @@ import { SlashCommandBuilder } from 'discord.js'; import { ACCESS_LEVELS, COLORS } from '../../config/constants.js'; import { asList, gitea, repositoryUrl } from '../../services/gitea/gitea-client.js'; import { replyGiteaFailure, assertGiteaConfigured } from '../../services/gitea/gitea-modals.js'; -import { baseEmbed, successEmbed } from '../../ui/embeds.js'; +import { baseEmbed, bullets, successEmbed } from '../../ui/embeds.js'; export const access = ACCESS_LEVELS.USER; @@ -13,13 +13,14 @@ export const data = new SlashCommandBuilder() .addSubcommand((sub) => sub.setName('release').setDescription('Releases disponibles')); const commitLines = (commits) => - asList(commits) - .slice(0, 5) - .map((commit) => { - const message = commit.commit?.message?.split('\n')[0] ?? '(sans message)'; - return `\`${commit.sha?.slice(0, 7)}\` ${message} — *${commit.commit?.author?.name ?? 'inconnu'}*`; - }) - .join('\n'); + bullets( + asList(commits) + .slice(0, 5) + .map((commit) => { + const message = commit.commit?.message?.split('\n')[0] ?? '(sans message)'; + return `\`${commit.sha?.slice(0, 7)}\` ${message} — *${commit.commit?.author?.name ?? 'un compte inconnu'}*`; + }), + ); /** Read-only summaries of the repository (M5-T06 / M5-T07). */ export async function execute(interaction) { @@ -35,7 +36,7 @@ export async function execute(interaction) { } const embed = baseEmbed(COLORS.gitea) - .setTitle('Releases FWS Arch') + .setTitle('📩 Releases FWS Arch') .setURL(repositoryUrl()) .setDescription( releases @@ -59,9 +60,9 @@ export async function execute(interaction) { ]); const embed = baseEmbed(COLORS.gitea) - .setTitle('ActivitĂ© rĂ©cente') + .setTitle('📈 ActivitĂ© rĂ©cente') .setURL(repositoryUrl()) - .setDescription(commitLines(commits) || 'Aucun commit rĂ©cent.') + .setDescription(commitLines(commits) || 'Aucun commit rĂ©cent pour le moment.') .addFields( { name: 'Issues ouvertes', value: String(asList(issues).length), inline: true }, { name: 'PR ouvertes', value: String(asList(pulls).length), inline: true }, diff --git a/src/commands/gitea/issue.js b/src/commands/gitea/issue.js index 64e0dc2..febdb38 100644 --- a/src/commands/gitea/issue.js +++ b/src/commands/gitea/issue.js @@ -8,7 +8,7 @@ import { openIssueModal, replyGiteaFailure, } from '../../services/gitea/gitea-modals.js'; -import { baseEmbed, successEmbed } from '../../ui/embeds.js'; +import { baseEmbed, bullets, successEmbed } from '../../ui/embeds.js'; export const access = ACCESS_LEVELS.USER; @@ -24,7 +24,7 @@ export const data = new SlashCommandBuilder() .setName('view') .setDescription('Afficher une issue') .addIntegerOption((option) => - option.setName('number').setDescription("NumĂ©ro de l'issue").setRequired(true).setMinValue(1), + option.setName('number').setDescription('NumĂ©ro de l’issue').setRequired(true).setMinValue(1), ), ) .addSubcommand((sub) => sub.setName('list').setDescription('Lister les issues ouvertes')); @@ -44,24 +44,33 @@ export async function execute(interaction) { try { if (subcommand === 'view') { const issue = await gitea.getIssue(interaction.options.getInteger('number', true)); - if (!issue?.number) throw new UserFacingError('Cette issue est introuvable sur Gitea.'); + if (!issue?.number) { + throw new UserFacingError( + 'Je ne trouve pas cette issue sur Gitea : vĂ©rifie son numĂ©ro avec `/issue list`.', + ); + } await interaction.editReply({ embeds: [issueEmbed(issue)] }); return; } const issues = asList(await gitea.listIssues('state=open&type=issues&limit=15')); if (issues.length === 0) { - await interaction.editReply({ embeds: [successEmbed('Aucune issue ouverte. 🎉')] }); + await interaction.editReply({ + embeds: [successEmbed('Aucune issue ouverte : rien en attente, tout est traitĂ© 🎉')], + }); return; } const embed = baseEmbed(COLORS.gitea) - .setTitle('Issues ouvertes') + .setTitle('🐙 Issues ouvertes') .setURL(`${repositoryUrl()}/issues`) .setDescription( - issues - .map((issue) => `**#${issue.number}** ${issue.title} — *${issue.user?.login ?? 'inconnu'}*`) - .join('\n'), + bullets( + issues.map( + (issue) => + `**#${issue.number}** ${issue.title} — ouverte par *${issue.user?.login ?? 'un compte inconnu'}*`, + ), + ), ) .setFooter({ text: `${issues.length} issue(s) affichĂ©e(s)` }); await interaction.editReply({ embeds: [embed] }); diff --git a/src/commands/gitea/pr.js b/src/commands/gitea/pr.js index a1af1c9..c9b7570 100644 --- a/src/commands/gitea/pr.js +++ b/src/commands/gitea/pr.js @@ -8,7 +8,7 @@ import { openPullRequestModal, replyGiteaFailure, } from '../../services/gitea/gitea-modals.js'; -import { baseEmbed, successEmbed } from '../../ui/embeds.js'; +import { baseEmbed, bullets, successEmbed } from '../../ui/embeds.js'; export const access = ACCESS_LEVELS.USER; export const subcommandAccess = { create: ACCESS_LEVELS.DEV }; @@ -20,8 +20,18 @@ export const data = new SlashCommandBuilder() sub .setName('create') .setDescription('CrĂ©er une pull request') - .addStringOption((option) => option.setName('head').setDescription('Branche source').setRequired(true)) - .addStringOption((option) => option.setName('base').setDescription('Branche cible').setRequired(true)), + .addStringOption((option) => + option + .setName('head') + .setDescription('Branche source, celle qui apporte les changements') + .setRequired(true), + ) + .addStringOption((option) => + option + .setName('base') + .setDescription('Branche cible, celle qui reçoit les changements') + .setRequired(true), + ), ) .addSubcommand((sub) => sub @@ -48,28 +58,34 @@ export async function execute(interaction) { try { if (subcommand === 'view') { const pull = await gitea.getPullRequest(interaction.options.getInteger('number', true)); - if (!pull?.number) throw new UserFacingError('Cette pull request est introuvable sur Gitea.'); + if (!pull?.number) { + throw new UserFacingError( + 'Je ne trouve pas cette pull request sur Gitea : vĂ©rifie son numĂ©ro avec `/pr list`.', + ); + } await interaction.editReply({ embeds: [pullRequestEmbed(pull)] }); return; } const pulls = asList(await gitea.listPullRequests('state=open&limit=15')); if (pulls.length === 0) { - await interaction.editReply({ embeds: [successEmbed('Aucune pull request ouverte.')] }); + await interaction.editReply({ + embeds: [successEmbed('Aucune pull request ouverte : rien Ă  relire pour le moment 🎉')], + }); return; } const embed = baseEmbed(COLORS.gitea) - .setTitle('Pull requests ouvertes') + .setTitle('🐙 Pull requests ouvertes') .setURL(`${repositoryUrl()}/pulls`) .setDescription( - pulls - .map( + bullets( + pulls.map( (pull) => `**#${pull.number}** ${pull.title} — ${pull.head?.ref ?? '?'} → ${pull.base?.ref ?? '?'} ` + - `(*${pull.user?.login ?? 'inconnu'}*)`, - ) - .join('\n'), + `(proposĂ©e par *${pull.user?.login ?? 'un compte inconnu'}*)`, + ), + ), ) .setFooter({ text: `${pulls.length} PR affichĂ©e(s)` }); await interaction.editReply({ embeds: [embed] }); diff --git a/src/commands/moderation/ban.js b/src/commands/moderation/ban.js index 0634ce1..08e8dc1 100644 --- a/src/commands/moderation/ban.js +++ b/src/commands/moderation/ban.js @@ -14,11 +14,11 @@ export const data = new SlashCommandBuilder() .setDescription('Bannir un membre') .setDefaultMemberPermissions(PermissionFlagsBits.BanMembers) .addUserOption((option) => option.setName('user').setDescription('Membre').setRequired(true)) - .addStringOption((option) => option.setName('reason').setDescription('Raison').setMaxLength(500)) + .addStringOption((option) => option.setName('reason').setDescription('Motif').setMaxLength(500)) .addIntegerOption((option) => option .setName('delete_days') - .setDescription('Supprimer les messages des N derniers jours') + .setDescription('Supprimer aussi les messages des N derniers jours (0 Ă  7)') .setMinValue(0) .setMaxValue(7), ); @@ -41,12 +41,16 @@ export async function execute(interaction) { await interaction.deferReply({ flags: MessageFlags.Ephemeral }); await interaction.guild.bans.create(user.id, { - reason: reason ?? `Banni par ${interaction.user.tag}`, + 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(`**${user.tag}** a Ă©tĂ© banni du serveur.`)], + embeds: [ + successEmbed( + `C’est fait : **${user.tag}** ne peut plus revenir sur le serveur. L’historique reste consultable avec \`/mod logs\`.`, + ), + ], }); } diff --git a/src/commands/moderation/clear.js b/src/commands/moderation/clear.js index 0462ad4..cf3568c 100644 --- a/src/commands/moderation/clear.js +++ b/src/commands/moderation/clear.js @@ -13,7 +13,7 @@ export const data = new SlashCommandBuilder() .addIntegerOption((option) => option .setName('amount') - .setDescription('Nombre de messages') + .setDescription('Nombre de messages Ă  supprimer (1 Ă  100)') .setRequired(true) .setMinValue(1) .setMaxValue(100), @@ -23,7 +23,9 @@ export const data = new SlashCommandBuilder() export async function execute(interaction) { const amount = interaction.options.getInteger('amount', true); if (!interaction.channel?.isTextBased() || !interaction.channel.bulkDelete) { - throw new UserFacingError('La suppression groupĂ©e n’est pas possible dans ce salon.'); + throw new UserFacingError( + 'Je ne peux pas supprimer plusieurs messages d’un coup ici : lance la commande dans un salon textuel.', + ); } await interaction.deferReply({ flags: MessageFlags.Ephemeral }); @@ -37,8 +39,10 @@ export async function execute(interaction) { await interaction.editReply({ embeds: [ successEmbed( - `${deleted.size} message(s) supprimĂ©(s) dans <#${interaction.channelId}>.` + - (deleted.size < amount ? '\n_Les messages de plus de 14 jours sont conservĂ©s par Discord._' : ''), + `C’est nettoyĂ© : ${deleted.size} message(s) supprimĂ©(s) dans <#${interaction.channelId}>.` + + (deleted.size < amount + ? '\n_Discord conserve les messages de plus de 14 jours : ils n’ont pas pu ĂȘtre retirĂ©s._' + : ''), ), ], }); diff --git a/src/commands/moderation/kick.js b/src/commands/moderation/kick.js index 9278343..0c009cb 100644 --- a/src/commands/moderation/kick.js +++ b/src/commands/moderation/kick.js @@ -15,7 +15,7 @@ export const data = new SlashCommandBuilder() .setDescription('Expulser un membre du serveur') .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers) .addUserOption((option) => option.setName('user').setDescription('Membre').setRequired(true)) - .addStringOption((option) => option.setName('reason').setDescription('Raison').setMaxLength(500)); + .addStringOption((option) => option.setName('reason').setDescription('Motif').setMaxLength(500)); /** Expels the member after the hierarchy checks (M8-T03 / M8-T06). */ export async function execute(interaction) { @@ -31,10 +31,14 @@ export async function execute(interaction) { embeds: [targetNoticeEmbed({ action: 'kick', guildName: interaction.guild.name, reason })], }) .catch(() => {}); - await target.kick(reason ?? `ExpulsĂ© par ${interaction.user.tag}`); + await target.kick(reason ?? `Expulsion demandĂ©e par ${interaction.user.tag}`); await logModerationAction(interaction, { action: 'kick', targetId: target.id, reason }); await interaction.editReply({ - embeds: [successEmbed(`**${target.user.tag}** a Ă©tĂ© expulsĂ© du serveur.`)], + embeds: [ + successEmbed( + `C’est fait : **${target.user.tag}** ne fait plus partie du serveur. La personne peut revenir avec une nouvelle invitation.`, + ), + ], }); } diff --git a/src/commands/moderation/mod.js b/src/commands/moderation/mod.js index 8e943d6..bab4bc3 100644 --- a/src/commands/moderation/mod.js +++ b/src/commands/moderation/mod.js @@ -25,7 +25,7 @@ function formatEntry(row) { 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 raison'}` + `↳ par <@${row.moderator_id}> · ${row.reason || 'sans motif'}` ); } @@ -41,13 +41,15 @@ export async function execute(interaction) { const embed = actions.length === 0 ? infoEmbed( - 'Historique de modĂ©ration', - user ? `Aucune action enregistrĂ©e contre ${user}.` : 'Aucune action enregistrĂ©e sur ce serveur.', + '📜 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') + .setTitle(user ? `📜 Historique de ${user.tag}` : '📜 DerniĂšres actions de modĂ©ration') .setDescription(actions.map(formatEntry).join('\n\n')) - .setFooter({ text: `${actions.length} derniĂšre(s) action(s)` }); + .setFooter({ text: `${actions.length} action(s) affichĂ©e(s)` }); await interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral }); } diff --git a/src/commands/moderation/mute.js b/src/commands/moderation/mute.js index 6f52db1..5e485c3 100644 --- a/src/commands/moderation/mute.js +++ b/src/commands/moderation/mute.js @@ -19,12 +19,12 @@ export const data = new SlashCommandBuilder() .addIntegerOption((option) => option .setName('minutes') - .setDescription('DurĂ©e en minutes') + .setDescription('DurĂ©e de la sanction, en minutes') .setRequired(true) .setMinValue(1) .setMaxValue(40_320), ) - .addStringOption((option) => option.setName('reason').setDescription('Raison').setMaxLength(500)); + .addStringOption((option) => option.setName('reason').setDescription('Motif').setMaxLength(500)); /** Applies a Discord timeout after the hierarchy checks (M8-T02 / M8-T07). */ export async function execute(interaction) { @@ -53,7 +53,9 @@ export async function execute(interaction) { await interaction.editReply({ embeds: [ - successEmbed(`**${target.user.tag}** est rĂ©duit au silence pendant **${formatDuration(durationMs)}**.`), + successEmbed( + `C’est fait : **${target.user.tag}** est en exclusion temporaire pour **${formatDuration(durationMs)}**, la personne ne peut plus Ă©crire pendant ce temps.`, + ), ], }); } diff --git a/src/commands/moderation/notify.js b/src/commands/moderation/notify.js index e60625a..7bd7706 100644 --- a/src/commands/moderation/notify.js +++ b/src/commands/moderation/notify.js @@ -6,7 +6,7 @@ import { removeNotificationChannel, setNotificationChannel, } from '../../database/repositories/notification-repository.js'; -import { baseEmbed, successEmbed } from '../../ui/embeds.js'; +import { baseEmbed, bullets, successEmbed } from '../../ui/embeds.js'; export const access = ACCESS_LEVELS.STAFF; @@ -58,7 +58,9 @@ export async function execute(interaction) { const channel = interaction.options.getChannel('channel', true); setNotificationChannel({ guildId: interaction.guildId, type, channelId: channel.id }); await interaction.reply({ - embeds: [successEmbed(`Les notifications **${type}** seront envoyĂ©es dans <#${channel.id}>.`)], + embeds: [ + successEmbed(`C’est notĂ© : les notifications **${type}** partent maintenant dans <#${channel.id}>.`), + ], flags: MessageFlags.Ephemeral, }); return; @@ -67,9 +69,15 @@ export async function execute(interaction) { if (subcommand === 'remove') { const type = interaction.options.getString('type', true); const removed = removeNotificationChannel(interaction.guildId, type); - if (!removed) throw new UserFacingError(`Aucun salon personnalisĂ© n’est configurĂ© pour **${type}**.`); + if (!removed) { + throw new UserFacingError( + `Le type **${type}** utilise dĂ©jĂ  la configuration par dĂ©faut : il n’y a rien Ă  retirer.`, + ); + } await interaction.reply({ - embeds: [successEmbed(`Les notifications **${type}** repassent Ă  la configuration par dĂ©faut.`)], + embeds: [ + successEmbed(`C’est fait : les notifications **${type}** repassent Ă  la configuration par dĂ©faut.`), + ], flags: MessageFlags.Ephemeral, }); return; @@ -81,15 +89,15 @@ export async function execute(interaction) { const lines = NOTIFICATION_TYPES.map((type) => { const channelId = overrides.get(type); return channelId - ? `\`${type}\` → <#${channelId}> _(personnalisĂ©)_` + ? `\`${type}\` → <#${channelId}> _(choisi sur ce serveur)_` : `\`${type}\` → _configuration par dĂ©faut_`; }); await interaction.reply({ embeds: [ baseEmbed() - .setTitle('Salons de notification') - .setDescription(lines.join('\n')) + .setTitle('🔔 Salons de notification') + .setDescription(`${bullets(lines)}\n\nPour changer une destination : \`/notify set\`.`) .setFooter({ text: `Serveur ${interaction.guildId}` }), ], flags: MessageFlags.Ephemeral, diff --git a/src/commands/moderation/role.js b/src/commands/moderation/role.js index 2ed2263..e1f674a 100644 --- a/src/commands/moderation/role.js +++ b/src/commands/moderation/role.js @@ -19,9 +19,12 @@ export const data = new SlashCommandBuilder() .addStringOption((option) => option .setName('action') - .setDescription('Action') + .setDescription('Ajouter ou retirer le rĂŽle') .setRequired(true) - .addChoices({ name: 'Ajouter', value: 'add' }, { name: 'Retirer', value: 'remove' }), + .addChoices( + { name: 'Ajouter le rĂŽle', value: 'add' }, + { name: 'Retirer le rĂŽle', value: 'remove' }, + ), ), ); @@ -33,26 +36,37 @@ export async function execute(interaction) { const adding = action === 'add'; if (role.id === interaction.guild.roles.everyone.id) { - throw new UserFacingError('Le rĂŽle @everyone ne peut pas ĂȘtre attribuĂ©.'); + throw new UserFacingError( + 'Le rĂŽle @everyone ne s’attribue pas : il est portĂ© par tout le monde Ă  la fois.', + ); } if (role.managed) { - throw new UserFacingError('Ce rĂŽle est gĂ©rĂ© par une intĂ©gration et ne peut pas ĂȘtre modifiĂ©.'); + throw new UserFacingError( + 'Ce rĂŽle appartient Ă  une intĂ©gration : Discord le gĂšre tout seul, je ne peux pas le modifier.', + ); } const bot = interaction.guild.members.me; if (bot && bot.roles.highest.comparePositionTo(role) <= 0) { - throw new UserFacingError('Mon rĂŽle est trop bas pour gĂ©rer ce rĂŽle.'); + throw new UserFacingError( + 'Je ne peux pas gĂ©rer ce rĂŽle : il est placĂ© plus haut que le mien. Remonte mon rĂŽle dans la hiĂ©rarchie du serveur, et je m’en occupe.', + ); } const target = await fetchTargetMember(interaction, user.id); const hasRole = target.roles.cache.has(role.id); - if (adding && hasRole) throw new UserFacingError(`**${target.user.tag}** possĂšde dĂ©jĂ  le rĂŽle ${role}.`); - if (!adding && !hasRole) - throw new UserFacingError(`**${target.user.tag}** ne possĂšde pas le rĂŽle ${role}.`); + if (adding && hasRole) { + throw new UserFacingError(`Rien Ă  faire : **${target.user.tag}** porte dĂ©jĂ  le rĂŽle ${role}.`); + } + if (!adding && !hasRole) { + throw new UserFacingError(`Rien Ă  retirer : **${target.user.tag}** n’a pas le rĂŽle ${role}.`); + } const isGuildOwner = interaction.guild.ownerId === interaction.user.id; if (!isGuildOwner && interaction.member.roles.highest.comparePositionTo(role) <= 0) { - throw new UserFacingError('Tu ne peux pas gĂ©rer un rĂŽle au-dessus ou Ă©gal au tien.'); + throw new UserFacingError( + 'Ce rĂŽle est au mĂȘme niveau (ou plus haut) que le tien : je ne peux pas y toucher. Demande Ă  quelqu’un de plus haut dans la hiĂ©rarchie.', + ); } await interaction.deferReply({ flags: MessageFlags.Ephemeral }); @@ -69,7 +83,9 @@ export async function execute(interaction) { }); await interaction.editReply({ embeds: [ - successEmbed(`Le rĂŽle ${role} a Ă©tĂ© ${adding ? 'ajoutĂ© Ă ' : 'retirĂ© de'} **${target.user.tag}**.`), + successEmbed( + `C’est fait : le rĂŽle ${role} a Ă©tĂ© ${adding ? 'ajoutĂ© Ă ' : 'retirĂ© de'} **${target.user.tag}**.`, + ), ], }); } diff --git a/src/commands/moderation/warn.js b/src/commands/moderation/warn.js index dbb4f7f..db2b6cd 100644 --- a/src/commands/moderation/warn.js +++ b/src/commands/moderation/warn.js @@ -17,7 +17,7 @@ export const data = new SlashCommandBuilder() .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers) .addUserOption((option) => option.setName('user').setDescription('Membre').setRequired(true)) .addStringOption((option) => - option.setName('reason').setDescription('Raison').setRequired(true).setMaxLength(500), + option.setName('reason').setDescription('Motif').setRequired(true).setMaxLength(500), ); /** Records the warning, notifies the member and logs it (M8-T01 / M8-T06). */ @@ -44,6 +44,10 @@ export async function execute(interaction) { .catch(() => {}); await interaction.editReply({ - embeds: [successEmbed(`**${target.user.tag}** a Ă©tĂ© averti (${total} avertissement(s) au total).`)], + 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.`, + ), + ], }); } diff --git a/src/commands/tickets/ticket.js b/src/commands/tickets/ticket.js index 5535632..39724fe 100644 --- a/src/commands/tickets/ticket.js +++ b/src/commands/tickets/ticket.js @@ -31,7 +31,7 @@ export const data = new SlashCommandBuilder() sub .setName('close') .setDescription('Fermer le ticket') - .addStringOption((option) => option.setName('reason').setDescription('Raison').setMaxLength(500)), + .addStringOption((option) => option.setName('reason').setDescription('Motif').setMaxLength(500)), ) .addSubcommand((sub) => sub.setName('claim').setDescription('Prendre le ticket en charge')) .addSubcommand((sub) => @@ -49,7 +49,11 @@ export async function execute(interaction) { await interaction.deferReply({ flags: MessageFlags.Ephemeral }); const channel = await createTicket(interaction, categoryId); await interaction.editReply({ - embeds: [successEmbed(`Ton ticket est ouvert : <#${channel.id}>`)], + embeds: [ + successEmbed( + `Ton ticket est ouvert : <#${channel.id}>. DĂ©cris ta demande dedans, une personne de l’équipe te rĂ©pond dĂšs que possible.`, + ), + ], }); return; } diff --git a/src/config/constants.js b/src/config/constants.js index aa1d0d3..814a8d7 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -20,6 +20,14 @@ export const ACCESS_LEVELS = Object.freeze({ OWNER: 3, }); +/** Same names for the same levels in every message (M12-T02). */ +export const ACCESS_LABELS = Object.freeze({ + [ACCESS_LEVELS.USER]: 'Membre', + [ACCESS_LEVELS.STAFF]: 'Staff', + [ACCESS_LEVELS.DEV]: 'Dev', + [ACCESS_LEVELS.OWNER]: 'Owner', +}); + /** Moderation actions: Discord label, embed color and stored duration (M8). */ export const MODERATION_ACTIONS = Object.freeze({ warn: { label: 'Avertissement', color: COLORS.warning, duration: false }, @@ -32,7 +40,7 @@ export const MODERATION_ACTIONS = Object.freeze({ /** Ticket categories and who can see them (M0-T05 / M6-T01). */ export const TICKET_CATEGORIES = Object.freeze([ - { id: 'support', label: 'Support utilisateur', scope: ['staff', 'owner'] }, + { id: 'support', label: 'Aide et support', scope: ['staff', 'owner'] }, { id: 'bug', label: 'Bug', scope: ['staff', 'dev', 'owner'] }, { id: 'dev-question', label: 'Question de dĂ©veloppement', scope: ['dev', 'owner'] }, { id: 'report', label: 'Signalement', scope: ['staff', 'owner'] }, diff --git a/src/core/errors.js b/src/core/errors.js index 19ebe5f..7697e8a 100644 --- a/src/core/errors.js +++ b/src/core/errors.js @@ -7,7 +7,9 @@ export class UserFacingError extends Error { } export class PermissionDeniedError extends UserFacingError { - constructor(message = "Tu n'as pas la permission d'utiliser cette commande.") { + constructor( + message = 'Cette action est rĂ©servĂ©e Ă  l’équipe pour l’instant. Demande Ă  une personne du staff si tu en as besoin.', + ) { super(message); this.name = 'PermissionDeniedError'; } diff --git a/src/events/interaction-create.js b/src/events/interaction-create.js index ae0b5c8..116b82d 100644 --- a/src/events/interaction-create.js +++ b/src/events/interaction-create.js @@ -1,4 +1,5 @@ import { Events, MessageFlags } from 'discord.js'; +import { ACCESS_LABELS } from '../config/constants.js'; import { PermissionDeniedError, UserFacingError } from '../core/errors.js'; import { createLogger } from '../core/logger.js'; import { hasAccess } from '../core/permissions.js'; @@ -37,7 +38,9 @@ async function runChatInputCommand(interaction) { const subcommand = interaction.options.getSubcommand(false); const requiredLevel = command.subcommandAccess?.[subcommand] ?? command.access; if (!hasAccess(interaction.member, requiredLevel)) { - throw new PermissionDeniedError(); + throw new PermissionDeniedError( + `Cette commande demande le niveau **${ACCESS_LABELS[requiredLevel]}**. Si tu en as besoin, demande Ă  une personne du staff : elle peut le faire pour toi.`, + ); } await command.execute(interaction); } @@ -77,6 +80,9 @@ export async function execute(_client, interaction) { } log.error(`Interaction failed: ${interaction.commandName ?? interaction.customId ?? 'unknown'}`, error); - await replyError(interaction, 'Une erreur inattendue est survenue. RĂ©essaie plus tard.').catch(() => {}); + await replyError( + interaction, + 'Quelque chose s’est mal passĂ© de mon cĂŽtĂ©, rien n’est perdu. RĂ©essaie dans un instant — je l’ai notĂ© dans mes logs, l’équipe pourra regarder si ça recommence.', + ).catch(() => {}); } } diff --git a/src/services/gitea/gitea-embeds.js b/src/services/gitea/gitea-embeds.js index fbdf84b..e6fdffd 100644 --- a/src/services/gitea/gitea-embeds.js +++ b/src/services/gitea/gitea-embeds.js @@ -10,23 +10,24 @@ export function truncate(text, max = DESCRIPTION_MAX) { return value.length > max ? `${value.slice(0, max - 1)}
` : value; } +/** Falls back to a neutral word: the value always sits next to a person, never a role. */ const authorOf = (source) => - source?.user?.login ?? source?.sender?.login ?? source?.author?.name ?? 'inconnu'; + source?.user?.login ?? source?.sender?.login ?? source?.author?.name ?? 'compte inconnu'; /** Shared header of an issue, used by `/issue` and the webhooks (M5-T02 / M9-T04). */ export function issueEmbed(issue) { const embed = baseEmbed(COLORS.gitea) .setTitle(`#${issue.number} ${issue.title}`) - .setDescription(truncate(issue.body) || 'Pas de description.') + .setDescription(truncate(issue.body) || 'Aucune description fournie.') .addFields( - { name: 'Auteur', value: authorOf(issue), inline: true }, + { name: 'Ouverte par', value: authorOf(issue), inline: true }, { name: 'État', value: issue.state === 'closed' ? 'FermĂ©e' : 'Ouverte', inline: true }, { name: 'Commentaires', value: String(issue.comments ?? 0), inline: true }, ); if (issue.html_url) embed.setURL(issue.html_url); const labels = (issue.labels ?? []).map((label) => label.name).filter(Boolean); - if (labels.length > 0) embed.addFields({ name: 'Labels', value: labels.join(', ') }); + if (labels.length > 0) embed.addFields({ name: 'Étiquettes', value: labels.join(', ') }); return embed; } @@ -35,9 +36,9 @@ export function pullRequestEmbed(pull) { const state = pull.merged ? 'FusionnĂ©e' : pull.state === 'closed' ? 'FermĂ©e' : 'Ouverte'; const embed = baseEmbed(COLORS.gitea) .setTitle(`PR #${pull.number} ${pull.title}`) - .setDescription(truncate(pull.body) || 'Pas de description.') + .setDescription(truncate(pull.body) || 'Aucune description fournie.') .addFields( - { name: 'Auteur', value: authorOf(pull), inline: true }, + { name: 'ProposĂ©e par', value: authorOf(pull), inline: true }, { name: 'État', value: state, inline: true }, { name: 'Branches', value: `${pull.head?.ref ?? '?'} → ${pull.base?.ref ?? '?'}`, inline: true }, ); @@ -74,12 +75,12 @@ export function pushEmbed(payload, maxCommits = 5) { const embed = baseEmbed(COLORS.gitea) .setTitle(`Push sur ${branch || 'le dĂ©pĂŽt'}`) - .setDescription(lines.join('\n') || 'Aucun commit dans cet Ă©vĂ©nement.') + .setDescription(lines.join('\n') || 'Aucun commit Ă  afficher pour cet Ă©vĂ©nement.') .addFields( - { name: 'Auteur', value: authorOf(payload), inline: true }, + { name: 'PoussĂ© par', value: authorOf(payload), inline: true }, { name: 'Commits', value: String(commits.length), inline: true }, ); - if (remaining > 0) embed.addFields({ name: 'Et', value: `${remaining} autre(s) commit(s)` }); + if (remaining > 0) embed.addFields({ name: 'Et aussi', value: `${remaining} commit(s) de plus` }); if (payload.repository?.html_url) embed.setURL(payload.repository.html_url); return embed; } diff --git a/src/services/gitea/gitea-modals.js b/src/services/gitea/gitea-modals.js index 45189aa..44c04fa 100644 --- a/src/services/gitea/gitea-modals.js +++ b/src/services/gitea/gitea-modals.js @@ -15,7 +15,9 @@ const PR_CONTEXT_TTL_MS = 10 * 60_000; /** Fails fast with an actionable message when Gitea is not configured (M5-T01). */ export function assertGiteaConfigured() { if (!isGiteaConfigured()) { - throw new UserFacingError('Gitea n’est pas configurĂ© : renseigne `GITEA_URL` et `GITEA_TOKEN`.'); + throw new UserFacingError( + 'La partie Gitea n’est pas encore configurĂ©e : il manque `GITEA_URL` et `GITEA_TOKEN` dans le `.env`. Tout le reste du bot fonctionne sans cela.', + ); } } @@ -68,8 +70,8 @@ export async function replyGiteaFailure(interaction, error) { log.error('Gitea request failed', error); const detail = error instanceof ExternalApiError && /not configured/.test(error.message) - ? 'Gitea n’est pas configurĂ©.' - : 'Gitea est momentanĂ©ment indisponible. RĂ©essaie dans quelques instants.'; + ? 'La partie Gitea n’est pas encore configurĂ©e : il manque `GITEA_URL` et `GITEA_TOKEN` dans le `.env`.' + : 'Gitea ne rĂ©pond pas pour le moment. RĂ©essaie dans quelques instants — si ça persiste, prĂ©viens l’équipe.'; const payload = { embeds: [errorEmbed(detail)], flags: MessageFlags.Ephemeral }; if (interaction.deferred || interaction.replied) { @@ -107,7 +109,9 @@ export async function submitPullRequestModal(interaction) { assertGiteaConfigured(); const context = consume(`pr:${interaction.user.id}`); if (!context) { - throw new UserFacingError('Session expirĂ©e : relance `/pr create` pour choisir Ă  nouveau les branches.'); + throw new UserFacingError( + 'La sĂ©lection des branches a expirĂ© : relance `/pr create` pour les choisir Ă  nouveau.', + ); } await interaction.deferReply(); diff --git a/src/services/members/member-service.js b/src/services/members/member-service.js index a8cb882..f3413bb 100644 --- a/src/services/members/member-service.js +++ b/src/services/members/member-service.js @@ -26,13 +26,13 @@ export async function sendWelcome(client, member) { } const embed = baseEmbed(COLORS.primary) - .setTitle('Nouveau membre !') - .setDescription(`${member} rejoint le serveur. ${DEFAULT_WELCOME}`) + .setTitle('🎉 Nouveau membre') + .setDescription(`${member} vient d’arriver. ${DEFAULT_WELCOME}`) .addFields({ name: 'Membres', value: String(member.guild.memberCount), inline: true }) .setThumbnail(member.user.displayAvatarURL({ size: 128 })); if (env.channels.rules) { - embed.addFields({ name: 'RĂšglement', value: `À lire dans <#${env.channels.rules}>` }); + embed.addFields({ name: 'RĂšglement', value: `À lire ici : <#${env.channels.rules}>` }); } await channel.send({ content: `${member}`, embeds: [embed] }); @@ -70,8 +70,8 @@ export async function sendWelcomeDirectMessage(member) { const embed = baseEmbed(COLORS.primary) .setTitle(`Bienvenue sur ${member.guild.name} !`) .setDescription( - 'Merci de rejoindre la communautĂ© FWS. Prends un instant pour lire le rĂšglement, ' + - 'puis prĂ©sente-toi si tu le souhaites.', + 'Merci d’avoir rejoint la communautĂ© FWS đŸŒ± Prends un instant pour lire le rĂšglement, ' + + 'puis prĂ©sente‑toi si tu le souhaites : on adore dĂ©couvrir les nouvelles personnes.', ); if (links.length > 0) embed.addFields({ name: 'Ressources', value: links.join('\n') }); @@ -90,7 +90,7 @@ export async function announceDeparture(client, member) { const joinedAt = member.joinedTimestamp; const embed = baseEmbed(COLORS.warning) - .setTitle('DĂ©part d’un membre') + .setTitle('👋 DĂ©part d’un membre') .setDescription(`${member.user.tag} a quittĂ© le serveur.`) .addFields( { name: 'Membres', value: String(member.guild.memberCount), inline: true }, diff --git a/src/services/moderation/moderation-service.js b/src/services/moderation/moderation-service.js index e7d1714..5b05656 100644 --- a/src/services/moderation/moderation-service.js +++ b/src/services/moderation/moderation-service.js @@ -12,17 +12,25 @@ import { baseEmbed } from '../../ui/embeds.js'; * @param {import('discord.js').GuildMember} target */ export function assertModerationTarget(interaction, target) { - if (!target) throw new UserFacingError('Ce membre n’est pas prĂ©sent sur le serveur.'); + if (!target) { + throw new UserFacingError( + 'Je ne trouve pas ce membre sur le serveur : vĂ©rifie qu’il y est toujours, puis relance la commande.', + ); + } if (target.id === interaction.user.id) { - throw new UserFacingError('Tu ne peux pas t’appliquer cette action Ă  toi-mĂȘme.'); + throw new UserFacingError('Tu ne peux pas t’appliquer cette action Ă  toi‑mĂȘme 😅 Vise un autre membre.'); } if (!canActOn(interaction.member, target)) { - throw new UserFacingError('Tu ne peux pas agir sur ce membre : son rĂŽle est Ă©gal ou supĂ©rieur au tien.'); + throw new UserFacingError( + 'Cette personne a un rĂŽle Ă©gal ou supĂ©rieur au tien : je ne peux pas la viser. Demande Ă  quelqu’un de plus haut dans la hiĂ©rarchie si c’est nĂ©cessaire.', + ); } const bot = interaction.guild.members.me; if (bot && bot.roles.highest.comparePositionTo(target.roles.highest) <= 0) { - throw new UserFacingError(`Mon rĂŽle est trop bas pour agir sur ${target.user.tag}.`); + throw new UserFacingError( + `Je ne peux pas agir sur ${target.user.tag} : mon rĂŽle est placĂ© plus bas que le sien. Remonte mon rĂŽle dans les paramĂštres du serveur, et je m’en occupe.`, + ); } } @@ -73,11 +81,11 @@ export async function sendModerationLog( const meta = MODERATION_ACTIONS[action]; const embed = baseEmbed(meta?.color) - .setTitle(`ModĂ©ration — ${meta?.label ?? action}`) + .setTitle(`đŸ›Ąïž ModĂ©ration — ${meta?.label ?? action}`) .addFields( - { name: 'Cible', value: targetId ? `<@${targetId}> (${targetId})` : 'Salon', inline: true }, - { name: 'ModĂ©rateur', value: `<@${moderatorId}>`, inline: true }, - { name: 'Raison', value: reason || 'Non prĂ©cisĂ©e' }, + { name: 'Membre', value: targetId ? `<@${targetId}> (${targetId})` : 'Salon', inline: true }, + { name: 'Par', value: `<@${moderatorId}>`, inline: true }, + { name: 'Motif', value: reason || 'Non prĂ©cisĂ©' }, ); if (durationMs) { embed.addFields({ name: 'DurĂ©e', value: formatDuration(durationMs), inline: true }); @@ -92,8 +100,10 @@ export function targetNoticeEmbed({ action, guildName, reason = null, durationMs const meta = MODERATION_ACTIONS[action]; const embed = baseEmbed(meta?.color) .setTitle(`Sanction sur ${guildName}`) - .setDescription(`Action : **${meta?.label ?? action}**`) - .addFields({ name: 'Raison', value: reason || 'Non prĂ©cisĂ©e' }); + .setDescription( + `Action : **${meta?.label ?? action}**\n\nCette dĂ©cision vient de l’équipe de modĂ©ration. Tu peux rĂ©pondre Ă  ce message pour en parler calmement avec elle.`, + ) + .addFields({ name: 'Motif', value: reason || 'Non prĂ©cisĂ©' }); if (durationMs) embed.addFields({ name: 'DurĂ©e', value: formatDuration(durationMs) }); return embed; } @@ -113,6 +123,10 @@ export function formatDuration(durationMs) { /** Fetches the member targeted by a command, with a clear error if absent. */ export async function fetchTargetMember(interaction, userId) { const member = await interaction.guild.members.fetch(userId).catch(() => null); - if (!member) throw new UserFacingError('Ce membre n’est pas prĂ©sent sur le serveur.'); + if (!member) { + throw new UserFacingError( + 'Je ne trouve pas ce membre sur le serveur : vĂ©rifie qu’il y est toujours, puis relance la commande.', + ); + } return member; } diff --git a/src/services/notifications/notification-service.js b/src/services/notifications/notification-service.js index f5dc686..faf139a 100644 --- a/src/services/notifications/notification-service.js +++ b/src/services/notifications/notification-service.js @@ -50,7 +50,9 @@ export async function notifyError(client, error, context = 'application') { log.error(`Notification error (${context})`, error); return notify(client, 'errors', { embeds: [ - errorEmbed(`Une erreur est survenue dans **${context}**.`).addFields({ + errorEmbed( + `Un incident est survenu dans **${context}**. Rien d’inquiĂ©tant pour les membres : je continue de fonctionner, mais l’équipe technique gagne Ă  y jeter un Ɠil.`, + ).addFields({ name: 'DĂ©tail', value: `\`${String(error?.message ?? error).slice(0, 500)}\``, }), diff --git a/src/services/polls/poll-service.js b/src/services/polls/poll-service.js index 7dd4a42..e2a0a1d 100644 --- a/src/services/polls/poll-service.js +++ b/src/services/polls/poll-service.js @@ -29,10 +29,14 @@ export function parseChoices(input, { min = CHOICES_MIN, max = POLL_CHOICES_MAX .filter(Boolean); if (choices.length < min || choices.length > max) { - throw new UserFacingError(`Un sondage doit proposer entre ${min} et ${max} choix sĂ©parĂ©s par « ; ».`); + throw new UserFacingError( + `Il faut entre ${min} et ${max} propositions, sĂ©parĂ©es par des points‑virgules. Exemple : \`Pizza ; Sushis ; Tacos\`.`, + ); } if (new Set(choices.map((choice) => choice.toLowerCase())).size !== choices.length) { - throw new UserFacingError('Les choix d’un sondage doivent ĂȘtre diffĂ©rents.'); + throw new UserFacingError( + 'Deux propositions identiques rendraient le vote ambigu : donne un libellĂ© diffĂ©rent Ă  chacune.', + ); } return choices; } @@ -60,7 +64,7 @@ export function buildPollEmbed(poll, counts = countVotes(poll.id)) { }); const embed = baseEmbed(COLORS.info) - .setTitle(`Sondage #${poll.id} — ${poll.question}`) + .setTitle(`📊 Sondage #${poll.id} — ${poll.question}`) .setDescription(lines.join('\n\n')) .addFields( { name: 'Votes', value: String(total), inline: true }, @@ -130,8 +134,12 @@ async function fetchPollMessage(interaction, poll) { /** Closes a poll and freezes its results (M10-T05). */ export async function closePollById(client, pollId) { const poll = getPoll(pollId); - if (!poll) throw new UserFacingError(`Le sondage **#${pollId}** n’existe pas.`); - if (poll.status === 'closed') throw new UserFacingError(`Le sondage **#${pollId}** est dĂ©jĂ  fermĂ©.`); + if (!poll) { + throw new UserFacingError(`Je ne trouve pas le sondage **#${pollId}** : il a peut‑ĂȘtre Ă©tĂ© supprimĂ©.`); + } + if (poll.status === 'closed') { + throw new UserFacingError(`Le sondage **#${pollId}** est dĂ©jĂ  fermĂ© — les rĂ©sultats sont figĂ©s.`); + } closePoll(pollId); const closed = { ...poll, status: 'closed' }; @@ -155,19 +163,19 @@ export async function handlePollComponent(interaction) { const [, rawId, rawIndex] = interaction.customId.split(':'); const poll = getPoll(Number(rawId)); if (!poll || poll.status !== 'open') { - throw new UserFacingError('Ce sondage est fermĂ©.'); + throw new UserFacingError('Ce sondage est terminĂ© : les boutons ne prennent plus les votes.'); } const choices = JSON.parse(poll.choices); const index = Number(rawIndex); if (!Number.isInteger(index) || index < 0 || index >= choices.length) { - throw new UserFacingError('Choix inconnu.'); + throw new UserFacingError('Cette proposition n’existe plus dans le sondage.'); } const result = castVote(poll.id, interaction.user.id, index); if (result === 'unchanged') { await interaction.reply({ - content: `Tu as dĂ©jĂ  votĂ© pour **${choices[index]}**.`, + content: `Ton vote est dĂ©jĂ  sur **${choices[index]}** — rien n’a bougĂ©.`, flags: MessageFlags.Ephemeral, }); return; @@ -179,8 +187,8 @@ export async function handlePollComponent(interaction) { await interaction.reply({ content: result === 'changed' - ? `Ton vote a Ă©tĂ© changĂ© pour **${choices[index]}**.` - : `Vote enregistrĂ© pour **${choices[index]}**.`, + ? `C’est notĂ© : ton vote va maintenant Ă  **${choices[index]}**.` + : `Merci ! Ton vote est sur **${choices[index]}**.`, flags: MessageFlags.Ephemeral, }); } diff --git a/src/services/tickets/ticket-service.js b/src/services/tickets/ticket-service.js index 8a90c29..214824e 100644 --- a/src/services/tickets/ticket-service.js +++ b/src/services/tickets/ticket-service.js @@ -37,10 +37,10 @@ export function canUseCategory(member, category) { function ticketEmbed(ticket, category) { const claimed = ticket.claimed_by ? `<@${ticket.claimed_by}>` : 'Personne'; return baseEmbed(COLORS.ticket) - .setTitle(`Ticket ${category.label} #${ticket.id}`) + .setTitle(`đŸŽ« Ticket ${category.label} #${ticket.id}`) .setDescription( - `<@${ticket.author_id}> dĂ©cris ici ta demande avec le plus de dĂ©tails possible : ` + - 'contexte, Ă©tapes de reproduction, messages d’erreur.', + `<@${ticket.author_id}> dĂ©cris ta demande ici, avec le plus de dĂ©tails possible : ` + + 'contexte, Ă©tapes pour reproduire, messages d’erreur. Plus tu en dis, plus vite on t’aide.', ) .addFields( { name: 'CatĂ©gorie', value: category.label, inline: true }, @@ -96,18 +96,28 @@ async function logTicket(client, embed) { /** Opens a private channel for the ticket (M6-T03). */ export async function createTicket(interaction, categoryId) { const category = findCategory(categoryId); - if (!category) throw new UserFacingError('CatĂ©gorie de ticket inconnue.'); + if (!category) { + throw new UserFacingError( + 'Je ne connais pas cette catĂ©gorie de ticket : `/ticket create` te propose la liste Ă  jour.', + ); + } if (!canUseCategory(interaction.member, category)) { - throw new UserFacingError(`Tu n’as pas accĂšs Ă  la catĂ©gorie **${category.label}**.`); + throw new UserFacingError( + `La catĂ©gorie **${category.label}** est rĂ©servĂ©e Ă  l’équipe. Tu peux ouvrir un ticket dans une autre catĂ©gorie : \`/ticket create\` te montre celles qui te sont ouvertes.`, + ); } if (!env.channels.ticketCategory) { - throw new UserFacingError('Le salon parent des tickets n’est pas configurĂ© (`CATEGORY_TICKETS_ID`).'); + throw new UserFacingError( + 'Les tickets ne sont pas encore installĂ©s : il manque `CATEGORY_TICKETS_ID` dans le `.env`. PrĂ©viens l’équipe !', + ); } const guild = interaction.guild; const parent = await guild.channels.fetch(env.channels.ticketCategory).catch(() => null); if (parent?.type !== ChannelType.GuildCategory) { - throw new UserFacingError('`CATEGORY_TICKETS_ID` ne pointe pas vers une catĂ©gorie Discord.'); + throw new UserFacingError( + '`CATEGORY_TICKETS_ID` ne pointe pas vers une catĂ©gorie Discord : je ne peux pas y crĂ©er de salon. L’équipe doit corriger le `.env`.', + ); } const channel = await guild.channels.create({ @@ -139,7 +149,9 @@ export async function createTicket(interaction, categoryId) { // The unique index rejects a second open ticket for the same author and category. await channel.delete('Ticket en doublon').catch(() => {}); log.warn('Duplicate ticket rejected', error); - throw new UserFacingError('Tu as dĂ©jĂ  un ticket ouvert dans cette catĂ©gorie.'); + throw new UserFacingError( + 'Tu as dĂ©jĂ  un ticket ouvert dans cette catĂ©gorie : continue dessus, ou ferme‑le avant d’en ouvrir un autre.', + ); } await channel.send({ @@ -157,9 +169,9 @@ export async function createTicket(interaction, categoryId) { await logTicket( interaction.client, baseEmbed(COLORS.ticket) - .setTitle('Ticket ouvert') + .setTitle('đŸŽ« Ticket ouvert') .setDescription(`<#${channel.id}> — ${category.label}`) - .addFields({ name: 'Auteur', value: `<@${ticket.author_id}>`, inline: true }), + .addFields({ name: 'Ouvert par', value: `<@${ticket.author_id}>`, inline: true }), ); return channel; @@ -169,10 +181,12 @@ export async function createTicket(interaction, categoryId) { export async function getChannelTicket(interaction) { const ticket = getTicketByChannel(interaction.channelId); if (!ticket) { - throw new UserFacingError('Cette action doit ĂȘtre lancĂ©e depuis un salon de ticket.'); + throw new UserFacingError( + 'Cette action se lance depuis un salon de ticket : ouvre‑en un avec `/ticket create`, ou place‑toi dans le bon salon.', + ); } if (ticket.status !== 'open') { - throw new UserFacingError('Ce ticket est dĂ©jĂ  fermĂ©.'); + throw new UserFacingError('Ce ticket est dĂ©jĂ  fermĂ© : il n’y a plus rien Ă  faire ici.'); } return ticket; } @@ -180,7 +194,7 @@ export async function getChannelTicket(interaction) { export async function claimTicket(interaction) { const ticket = await getChannelTicket(interaction); if (ticket.claimed_by === interaction.user.id) { - throw new UserFacingError('Tu as dĂ©jĂ  pris ce ticket en charge.'); + throw new UserFacingError('Tu as dĂ©jĂ  ce ticket en charge — il n’y a rien Ă  changer.'); } claimTicketRow(ticket.id, interaction.user.id); @@ -192,14 +206,14 @@ export async function claimTicket(interaction) { }); await interaction.reply({ - embeds: [successEmbed(`<@${interaction.user.id}> prend ce ticket en charge.`)], + embeds: [successEmbed(`C’est notĂ© : <@${interaction.user.id}> prend ce ticket en charge. Merci !`)], }); await logTicket( interaction.client, baseEmbed(COLORS.ticket) - .setTitle('Ticket pris en charge') + .setTitle('đŸŽ« Ticket pris en charge') .setDescription(`#${ticket.id} — <#${ticket.channel_id}>`) - .addFields({ name: 'Staff', value: `<@${interaction.user.id}>`, inline: true }), + .addFields({ name: 'Avec', value: `<@${interaction.user.id}>`, inline: true }), ); } @@ -208,7 +222,9 @@ export async function closeTicket(interaction, reason = null) { const ticket = await getChannelTicket(interaction); const isStaff = getAccessLevel(interaction.member) >= ACCESS_LEVELS.STAFF; if (interaction.user.id !== ticket.author_id && !isStaff) { - throw new PermissionDeniedError('Seul l’auteur du ticket ou le staff peut le fermer.'); + throw new PermissionDeniedError( + 'Seules la personne qui a ouvert ce ticket et l’équipe peuvent le fermer. Si besoin, demande‑le dans le salon.', + ); } closeTicketRow(ticket.id, { closedBy: interaction.user.id, reason }); @@ -221,18 +237,20 @@ export async function closeTicket(interaction, reason = null) { await interaction.reply({ embeds: [ - successEmbed(`Ticket fermĂ© par <@${interaction.user.id}>. Le salon sera supprimĂ© dans 10 secondes.`), + successEmbed( + `Ticket fermĂ© par <@${interaction.user.id}> — merci ! Le salon disparaĂźt dans 10 secondes, tu as le temps de copier ce qui t’intĂ©resse.`, + ), ], }); await logTicket( interaction.client, baseEmbed(COLORS.ticket) - .setTitle('Ticket fermĂ©') + .setTitle('đŸŽ« Ticket fermĂ©') .setDescription(`#${ticket.id} — ${findCategory(ticket.category_id)?.label ?? ticket.category_id}`) .addFields( - { name: 'Auteur', value: `<@${ticket.author_id}>`, inline: true }, + { name: 'Ouvert par', value: `<@${ticket.author_id}>`, inline: true }, { name: 'FermĂ© par', value: `<@${interaction.user.id}>`, inline: true }, - { name: 'Raison', value: reason || 'Non prĂ©cisĂ©e' }, + { name: 'Motif', value: reason || 'Non prĂ©cisĂ©' }, ), ); @@ -244,7 +262,7 @@ export async function closeTicket(interaction, reason = null) { export async function addParticipant(interaction, userId) { const ticket = await getChannelTicket(interaction); if (userId === ticket.author_id || userId === ticket.claimed_by) { - throw new UserFacingError('Ce membre participe dĂ©jĂ  au ticket.'); + throw new UserFacingError('Cette personne est dĂ©jĂ  dans le ticket — pas besoin de l’ajouter.'); } await interaction.channel.permissionOverwrites.edit(userId, { @@ -259,7 +277,7 @@ export async function addParticipant(interaction, userId) { actorId: interaction.user.id, payload: { ticketId: ticket.id, userId }, }); - await interaction.reply({ embeds: [successEmbed(`<@${userId}> a Ă©tĂ© ajoutĂ© au ticket.`)] }); + await interaction.reply({ embeds: [successEmbed(`C’est notĂ© : <@${userId}> rejoint ce ticket.`)] }); } /** Routes the buttons posted in ticket channels. */ diff --git a/src/services/voice/voice-service.js b/src/services/voice/voice-service.js index 1734a70..65ac55f 100644 --- a/src/services/voice/voice-service.js +++ b/src/services/voice/voice-service.js @@ -82,7 +82,7 @@ const clean = (value) => /** Channel names are normalised and truncated before they reach Discord (M14-T08). */ export function sanitizeChannelName(value) { const name = clean(value); - if (!name) throw new UserFacingError('Le nom du salon ne peut pas ĂȘtre vide.'); + if (!name) throw new UserFacingError('Il me manque un nom : Ă©cris au moins un caractĂšre pour ton salon.'); return name.slice(0, NAME_MAX); } @@ -271,7 +271,7 @@ export function voicePanelEmbed(channel, row) { return baseEmbed(COLORS.primary) .setTitle(`Gestion de ${channel.name}`) .setDescription( - 'Les boutons ci-dessous agissent sur ce salon uniquement. Les commandes `/voice` offrent les mĂȘmes options.', + 'Les boutons ci-dessous agissent sur ce salon seulement. Tu retrouves exactement les mĂȘmes options dans `/voice`.', ) .addFields( { name: 'PropriĂ©taire', value: ownerId ? `<@${ownerId}>` : 'Personne', inline: true }, @@ -305,7 +305,8 @@ export function voiceInfoEmbed(channel, row) { ) .addFields({ name: 'Créé', value: ``, inline: true }); - if (row?.trigger_id) embed.setFooter({ text: `Salon temporaire · dĂ©clencheur ${row.trigger_id}` }); + if (row?.trigger_id) + embed.setFooter({ text: `Salon temporaire · créé depuis le dĂ©clencheur ${row.trigger_id}` }); return embed; } @@ -598,7 +599,9 @@ export async function resolveManagedChannel(interaction, { channelId = null } = /** Only the owner may manage a channel; staff can always step in (M14-T06). */ export function assertVoiceOwner(interaction, row, action = 'gĂ©rer ce salon') { if (row.owner_id === interaction.user.id || isStaff(interaction.member)) return; - throw new PermissionDeniedError(`Seul le propriĂ©taire du salon (ou le staff) peut ${action}.`); + throw new PermissionDeniedError( + `Ce salon appartient Ă  <@${row.owner_id}> : seule cette personne (ou l’équipe) peut ${action}.`, + ); } const ephemeral = (payload) => ({ ...payload, flags: MessageFlags.Ephemeral }); @@ -612,7 +615,9 @@ export async function renameChannel(interaction, name) { setVoiceName(channel.id, sanitized); await refreshPanel(channel); - await interaction.reply(ephemeral({ embeds: [successEmbed(`Salon renommĂ© en **${sanitized}**.`)] })); + await interaction.reply( + ephemeral({ embeds: [successEmbed(`Ton salon s’appelle maintenant **${sanitized}**.`)] }), + ); } export async function setChannelLimit(interaction, limit) { @@ -628,7 +633,9 @@ export async function setChannelLimit(interaction, limit) { ephemeral({ embeds: [ successEmbed( - value === 0 ? 'Le salon redevient **sans limite** de places.' : `Limite : **${value} places**.`, + value === 0 + ? 'Ton salon n’a plus de limite de places : tout le monde peut entrer.' + : `Ton salon accueille maintenant **${value} personnes**.`, ), ], }), @@ -641,7 +648,11 @@ export async function toggleLock(interaction, { locked = null } = {}) { const next = locked === null ? !row.locked : Boolean(locked); if (next === Boolean(row.locked)) { - throw new UserFacingError(next ? 'Le salon est dĂ©jĂ  verrouillĂ©.' : 'Le salon est dĂ©jĂ  dĂ©verrouillĂ©.'); + throw new UserFacingError( + next + ? 'Ton salon est dĂ©jĂ  verrouillĂ© — il n’y a rien Ă  changer.' + : 'Ton salon est dĂ©jĂ  ouvert — il n’y a rien Ă  changer.', + ); } await channel.permissionOverwrites.edit( interaction.guild.roles.everyone.id, @@ -656,8 +667,8 @@ export async function toggleLock(interaction, { locked = null } = {}) { embeds: [ successEmbed( next - ? '🔒 Salon verrouillĂ© : seuls les membres autorisĂ©s peuvent le rejoindre.' - : '🔓 Salon dĂ©verrouillĂ© : tout le monde peut rejoindre.', + ? '🔒 Salon verrouillĂ© : seules les personnes que tu autorises peuvent entrer.' + : '🔓 Salon ouvert : tout le monde peut entrer.', ), ], }), @@ -675,7 +686,9 @@ export async function permitUser(interaction, userId) { reason: `AutorisĂ© par ${interaction.user.tag}`, }, ); - await interaction.reply(ephemeral({ embeds: [successEmbed(`<@${userId}> peut rejoindre le salon.`)] })); + await interaction.reply( + ephemeral({ embeds: [successEmbed(`C’est notĂ© : <@${userId}> peut entrer dans ton salon.`)] }), + ); } export async function rejectUser(interaction, userId) { @@ -693,7 +706,7 @@ export async function rejectUser(interaction, userId) { await member?.voice.disconnect(`RefusĂ© par ${interaction.user.tag}`).catch(() => {}); await interaction.reply( - ephemeral({ embeds: [successEmbed(`<@${userId}> ne peut plus rejoindre le salon.`)] }), + ephemeral({ embeds: [successEmbed(`C’est notĂ© : <@${userId}> ne peut plus entrer dans ton salon.`)] }), ); } @@ -702,11 +715,14 @@ export async function kickUser(interaction, userId) { assertVoiceOwner(interaction, row, 'exclure un membre'); const member = channel.members.get(userId); - if (!member) throw new UserFacingError('Ce membre n’est pas dans le salon.'); - if (member.id === row.owner_id) throw new UserFacingError('Le propriĂ©taire ne peut pas ĂȘtre exclu.'); + if (!member) throw new UserFacingError('Ce membre n’est pas dans ton salon — il n’y a rien Ă  faire.'); + if (member.id === row.owner_id) + throw new UserFacingError('Impossible : la personne propriĂ©taire du salon ne peut pas en ĂȘtre exclue.'); await member.voice.disconnect(`Exclu par ${interaction.user.tag}`); - await interaction.reply(ephemeral({ embeds: [successEmbed(`<@${userId}> a Ă©tĂ© exclu du salon.`)] })); + await interaction.reply( + ephemeral({ embeds: [successEmbed(`<@${userId}> ne fait plus partie de ton salon.`)] }), + ); } export async function transferOwnership(interaction, userId) { @@ -714,8 +730,12 @@ export async function transferOwnership(interaction, userId) { assertVoiceOwner(interaction, row, 'transfĂ©rer le salon'); const member = channel.members.get(userId); - if (!member) throw new UserFacingError('Le nouveau propriĂ©taire doit dĂ©jĂ  ĂȘtre dans le salon.'); - if (member.id === row.owner_id) throw new UserFacingError('Ce membre est dĂ©jĂ  propriĂ©taire du salon.'); + if (!member) + throw new UserFacingError( + 'Cette personne doit dĂ©jĂ  ĂȘtre dans le salon pour en devenir propriĂ©taire : invite‑la, puis relance la commande.', + ); + if (member.id === row.owner_id) + throw new UserFacingError('Cette personne est dĂ©jĂ  propriĂ©taire de ce salon.'); await channel.permissionOverwrites .edit(row.owner_id, { ManageChannels: null, MoveMembers: null }, { reason: 'Nouveau propriĂ©taire' }) @@ -735,7 +755,9 @@ export async function transferOwnership(interaction, userId) { await interaction.reply( ephemeral({ - embeds: [successEmbed(`<@${member.id}> est dĂ©sormais propriĂ©taire de **${channel.name}**.`)], + embeds: [ + successEmbed(`<@${member.id}> est dĂ©sormais propriĂ©taire de **${channel.name}**. Bonne session !`), + ], }), ); } @@ -744,13 +766,17 @@ export async function transferOwnership(interaction, userId) { export async function claimOwnership(interaction) { const { channel, row } = await resolveManagedChannel(interaction); if (row.owner_id === interaction.user.id) { - throw new UserFacingError('Tu es dĂ©jĂ  propriĂ©taire de ce salon.'); + throw new UserFacingError('Tu es dĂ©jĂ  propriĂ©taire de ce salon — tout est en ordre.'); } if (channel.members.has(row.owner_id)) { - throw new UserFacingError('Le propriĂ©taire est toujours dans le salon.'); + throw new UserFacingError( + 'La personne propriĂ©taire est encore dans le salon : ce salon n’est pas abandonnĂ©.', + ); } if (!channel.members.has(interaction.user.id)) { - throw new UserFacingError('Rejoins d’abord le salon pour en rĂ©clamer la propriĂ©tĂ©.'); + throw new UserFacingError( + 'Entre d’abord dans le salon, puis relance la commande : la propriĂ©tĂ© se rĂ©clame depuis l’intĂ©rieur.', + ); } await channel.permissionOverwrites.edit(interaction.user.id, OWNER_OVERWRITE, { @@ -765,7 +791,9 @@ export async function claimOwnership(interaction) { payload: { channelId: channel.id }, }); - await interaction.reply(ephemeral({ embeds: [successEmbed('Tu es dĂ©sormais propriĂ©taire de ce salon.')] })); + await interaction.reply( + ephemeral({ embeds: [successEmbed('Tu es dĂ©sormais propriĂ©taire de ce salon. Amuse‑toi bien !')] }), + ); } export async function removeChannel(interaction, { channelId = null } = {}) { diff --git a/src/ui/embeds.js b/src/ui/embeds.js index 50c0c08..610f2b1 100644 --- a/src/ui/embeds.js +++ b/src/ui/embeds.js @@ -1,6 +1,25 @@ import { EmbedBuilder } from 'discord.js'; import { BOT_NAME, COLORS } from '../config/constants.js'; +/** + * Bot voice — one tone everywhere (M12-T02). Every user-facing string in the project follows + * these rules, so the messages stay consistent as commands are added: + * + * - Informal French, short sentences, active voice; never a reproach or irony. + * - The title states the outcome, the description says what to do next. + * - One emoji per title, never decorative inside the body. + * - No gendered agreement on a person: "tu es propriĂ©taire", "ce membre", "l'Ă©quipe", + * "la personne" — never "il / elle", "cher / chĂšre", "ravi·e". + * - An error explains the cause, recalls the rule and offers the way out. + * - Same vocabulary across modules: Ă©quipe, membre, salon, ticket, motif. + */ +export const TONE = Object.freeze({ + success: '✅ C’est fait', + error: '❌ Oups', + warning: '⚠ Attention', + advice: '💡 Bon Ă  savoir', +}); + /** Base embed with the shared FWS-Bot visual identity (M12-T02). */ export function baseEmbed(color = COLORS.primary) { return new EmbedBuilder().setColor(color).setFooter({ text: BOT_NAME }).setTimestamp(); @@ -10,10 +29,27 @@ export function infoEmbed(title, description) { return baseEmbed(COLORS.info).setTitle(title).setDescription(description); } -export function successEmbed(description) { - return baseEmbed(COLORS.success).setTitle('SuccĂšs').setDescription(description); +export function successEmbed(description, { title = TONE.success } = {}) { + return baseEmbed(COLORS.success).setTitle(title).setDescription(description); } -export function errorEmbed(description) { - return baseEmbed(COLORS.error).setTitle('Erreur').setDescription(description); +export function warningEmbed(description, { title = TONE.warning } = {}) { + return baseEmbed(COLORS.warning).setTitle(title).setDescription(description); +} + +export function errorEmbed(description, { title = TONE.error } = {}) { + return baseEmbed(COLORS.error).setTitle(title).setDescription(description); +} + +/** Uniform list marker, so every embed lists things the same way. */ +export function bullets(lines) { + return lines + .filter(Boolean) + .map((line) => `‱ ${line}`) + .join('\n'); +} + +/** Adds the "what you can do now" line that most replies end with. */ +export function withHint(description, hint) { + return hint ? `${description}\n\n${hint}` : description; } diff --git a/tests/modules.test.js b/tests/modules.test.js index f087eb4..092f2ce 100644 --- a/tests/modules.test.js +++ b/tests/modules.test.js @@ -46,6 +46,34 @@ describe('command modules', () => { }); }); +describe('message tone', () => { + it('builds every embed with the shared titles, marker and hint', async () => { + const { TONE, bullets, errorEmbed, successEmbed, warningEmbed, withHint } = + await import('../src/ui/embeds.js'); + + assert.equal(successEmbed('x').data.title, TONE.success); + assert.equal(errorEmbed('x').data.title, TONE.error); + assert.equal(warningEmbed('x').data.title, TONE.warning); + assert.equal(bullets(['a', 'b', '']), '‱ a\n‱ b'); + assert.equal(withHint('fait', 'ensuite'), 'fait\n\nensuite'); + assert.equal(withHint('fait', null), 'fait'); + }); + + it('keeps command descriptions free of gendered wording', async () => { + /** Words that would address or describe a person with a gender. */ + const gendered = + /\b(utilisateur|utilisatrice|cher|chĂšre|ravi|ravie|content|contente|bienvenu|bienvenue Ă  (lui|elle))/i; + + for (const command of await loadCommands()) { + const json = command.data.toJSON(); + const texts = [json.description, ...(json.options ?? []).map((option) => option.description ?? '')]; + for (const text of texts) { + assert.ok(!gendered.test(text), `/${json.name} uses gendered wording: ${text}`); + } + } + }); +}); + describe('webhook entry points', () => { it('exposes the server and the dispatch functions', async () => { const server = await import('../src/webhooks/server.js'); diff --git a/tests/poll-service.test.js b/tests/poll-service.test.js index 9d644d9..3d1ea56 100644 --- a/tests/poll-service.test.js +++ b/tests/poll-service.test.js @@ -9,11 +9,11 @@ describe('parseChoices', () => { }); it('rejects a single choice', () => { - assert.throws(() => parseChoices('Oui'), /entre 2 et 10 choix/); + assert.throws(() => parseChoices('Oui'), /entre 2 et 10 propositions/); }); it('rejects duplicated choices regardless of case', () => { - assert.throws(() => parseChoices('Oui;oui'), /diffĂ©rents/); + assert.throws(() => parseChoices('Oui;oui'), /Deux propositions identiques/); }); it('rejects more choices than allowed', () => { @@ -42,7 +42,7 @@ describe('buildPollEmbed', () => { { choice_index: 0, count: 3 }, { choice_index: 1, count: 1 }, ]); - assert.equal(embed.data.title, 'Sondage #3 — Quel thĂšme ?'); + assert.equal(embed.data.title, '📊 Sondage #3 — Quel thĂšme ?'); assert.match(embed.data.description, /Clair/); assert.match(embed.data.description, /3 \(75 %\)/); assert.equal(embed.data.fields[0].value, '4');