feat(tickets): guide members in ticket channels and log to the technical salon
CI / quality (push) Has been cancelled
CI / quality (push) Has been cancelled
Tickets were opened with three words and members expected an immediate answer, so the channel now posts a guidance embed: what details to give (context, steps to reproduce, exact error, OS version) and that a reply can take a while. The ticket journal moves to CHANNEL_LOGS_ID so the environment keeps one log salon per purpose: CHANNEL_TICKETS_LOGS_ID held the same entries and nothing else read it. A wrong CATEGORY_TICKETS_ID now says which case it is, since a missing category was reported as a mistyped one.
This commit is contained in:
7 files changed
+187
-23
No files matched your search
@@ -43,7 +43,6 @@ export const env = Object.freeze({
|
||||
announcements: read('CHANNEL_ANNOUNCEMENTS_ID'),
|
||||
logs: read('CHANNEL_LOGS_ID'),
|
||||
modLogs: read('CHANNEL_MOD_LOGS_ID'),
|
||||
ticketLogs: read('CHANNEL_TICKETS_LOGS_ID'),
|
||||
notifIssues: read('CHANNEL_NOTIF_ISSUES_ID'),
|
||||
notifPullRequests: read('CHANNEL_NOTIF_PULL_REQUESTS_ID'),
|
||||
notifCommits: read('CHANNEL_NOTIF_COMMITS_ID'),
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
getTicketByChannel,
|
||||
} from '../../database/repositories/ticket-repository.js';
|
||||
import { ticketButtons } from '../../ui/buttons.js';
|
||||
import { baseEmbed, successEmbed } from '../../ui/embeds.js';
|
||||
import { TONE, baseEmbed, bullets, successEmbed } from '../../ui/embeds.js';
|
||||
|
||||
const log = createLogger('tickets');
|
||||
|
||||
@@ -39,10 +39,7 @@ function ticketEmbed(ticket, category) {
|
||||
const claimed = ticket.claimed_by ? `<@${ticket.claimed_by}>` : 'Personne';
|
||||
return baseEmbed(COLORS.ticket)
|
||||
.setTitle(`🎫 Ticket ${category.label} #${ticket.id}`)
|
||||
.setDescription(
|
||||
`<@${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.',
|
||||
)
|
||||
.setDescription(`<@${ticket.author_id}> décris ta demande ici, l’équipe lit ce salon.`)
|
||||
.addFields(
|
||||
{ name: 'Catégorie', value: category.label, inline: true },
|
||||
{ name: 'Statut', value: ticket.status === 'open' ? 'Ouvert' : 'Fermé', inline: true },
|
||||
@@ -50,6 +47,37 @@ function ticketEmbed(ticket, category) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guidance posted under the ticket header: what to write, and that an answer can
|
||||
* take a while. Members often open a ticket with three words and wait.
|
||||
*/
|
||||
function ticketHelpEmbed() {
|
||||
return baseEmbed(COLORS.info)
|
||||
.setTitle(TONE.advice)
|
||||
.setDescription(
|
||||
'Détaille au maximum : tout ce que tu écris ici nous évite de te poser des questions pour rien.',
|
||||
)
|
||||
.addFields(
|
||||
{
|
||||
name: 'Ce qui nous aide',
|
||||
value: bullets([
|
||||
'ce que tu voulais faire, et ce qui s’est passé à la place',
|
||||
'les étapes pour reproduire le problème, une par une',
|
||||
'le message d’erreur exact, en photo ou recopié tel quel',
|
||||
'ta version de l’OS, et ce que tu viens d’installer',
|
||||
]),
|
||||
},
|
||||
{
|
||||
name: 'Ça peut prendre un peu de temps',
|
||||
value: bullets([
|
||||
'ce salon est privé : toi, l’équipe et les personnes que vous ajoutez y voient ces messages',
|
||||
'l’équipe répond ici, donc ne cherche pas ailleurs pour suivre ton ticket',
|
||||
'une fois ta demande réglée, ferme le ticket avec le bouton **Fermer**',
|
||||
]),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function channelName(categoryId, username) {
|
||||
const slug = username
|
||||
.toLowerCase()
|
||||
@@ -83,9 +111,10 @@ function buildOverwrites(guild, client, category, authorId) {
|
||||
return overwrites;
|
||||
}
|
||||
|
||||
/** The ticket journal lives in the technical logs salon (`CHANNEL_LOGS_ID`). */
|
||||
async function fetchTicketLogChannel(client) {
|
||||
if (!env.channels.ticketLogs) return null;
|
||||
const channel = await client.channels.fetch(env.channels.ticketLogs).catch(() => null);
|
||||
if (!env.channels.logs) return null;
|
||||
const channel = await client.channels.fetch(env.channels.logs).catch(() => null);
|
||||
return channel?.isSendable() ? channel : null;
|
||||
}
|
||||
|
||||
@@ -115,7 +144,14 @@ export async function createTicket(interaction, categoryId) {
|
||||
|
||||
const guild = interaction.guild;
|
||||
const parent = await guild.channels.fetch(env.channels.ticketCategory).catch(() => null);
|
||||
if (parent?.type !== ChannelType.GuildCategory) {
|
||||
if (!parent) {
|
||||
log.warn('Ticket category is unreachable', { categoryId: env.channels.ticketCategory });
|
||||
throw new UserFacingError(
|
||||
'`CATEGORY_TICKETS_ID` ne pointe vers aucun salon accessible : je ne peux pas y créer de salon. L’équipe doit corriger le `.env`.',
|
||||
);
|
||||
}
|
||||
if (parent.type !== ChannelType.GuildCategory) {
|
||||
log.warn('Ticket category is not a category', { categoryId: parent.id, type: parent.type });
|
||||
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`.',
|
||||
);
|
||||
@@ -157,7 +193,7 @@ export async function createTicket(interaction, categoryId) {
|
||||
|
||||
await channel.send({
|
||||
content: `<@${ticket.author_id}>`,
|
||||
embeds: [ticketEmbed(ticket, category)],
|
||||
embeds: [ticketEmbed(ticket, category), ticketHelpEmbed()],
|
||||
components: ticketButtons(),
|
||||
});
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ export const VARIABLES = Object.freeze([
|
||||
key: 'CHANNEL_LOGS_ID',
|
||||
section: 'channels',
|
||||
label: 'Salon des logs techniques',
|
||||
help: 'Erreurs et événements techniques du bot.',
|
||||
help: 'Erreurs, événements techniques du bot et journal des tickets.',
|
||||
type: 'snowflake',
|
||||
},
|
||||
{
|
||||
@@ -233,13 +233,6 @@ export const VARIABLES = Object.freeze([
|
||||
help: 'Avertissements, mises en sourdine, bannissements.',
|
||||
type: 'snowflake',
|
||||
},
|
||||
{
|
||||
key: 'CHANNEL_TICKETS_LOGS_ID',
|
||||
section: 'channels',
|
||||
label: 'Salon des logs de tickets',
|
||||
help: 'Ouverture, prise en charge et clôture des tickets.',
|
||||
type: 'snowflake',
|
||||
},
|
||||
{
|
||||
key: 'CHANNEL_NOTIF_ISSUES_ID',
|
||||
section: 'channels',
|
||||
|
||||
Reference in new issue
Block a user