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:
31 files changed
+469
-201
No files matched your search
@@ -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 } = {}) {
|
||||
|
||||
Reference in new issue
Block a user