refactor(ui): give every message one friendly, ungendered voice

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.
This commit is contained in:
BlackAngelTV committed 2026-09-15 16:12:19 +02:00
1 parent 76e2269555
commit ef8f09da10
31 files changed
+469 -201

No files matched your search

+10 -9
View File
@@ -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;
}
+8 -4
View File
@@ -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();
+6 -6
View File
@@ -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 },
+25 -11
View File
@@ -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;
}
@@ -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)}\``,
}),
+18 -10
View File
@@ -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,
});
}
+41 -23
View File
@@ -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. */
+49 -21
View File
@@ -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: `<t:${Math.floor(channel.createdTimestamp / 1000)}:R>`, 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 } = {}) {