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
@@ -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)}**`),
|
||||
],
|
||||
});
|
||||
|
||||
@@ -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.`,
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -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.',
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
+36
-16
@@ -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: `<t:${Math.floor((Date.now() - uptime * 1000) / 1000)}:R>` },
|
||||
{ name: 'En ligne depuis', value: `<t:${Math.floor((Date.now() - uptime * 1000) / 1000)}:R>` },
|
||||
);
|
||||
|
||||
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;
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
+12
-11
@@ -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 },
|
||||
|
||||
@@ -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] });
|
||||
|
||||
+27
-11
@@ -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] });
|
||||
|
||||
@@ -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\`.`,
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -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._'
|
||||
: ''),
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
@@ -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.`,
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -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 });
|
||||
}
|
||||
@@ -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.`,
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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}**.`,
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -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.`,
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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'] },
|
||||
|
||||
+3
-1
@@ -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';
|
||||
}
|
||||
|
||||
@@ -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(() => {});
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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)}\``,
|
||||
}),
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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 } = {}) {
|
||||
|
||||
+40
-4
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user