Update Bot (j'ai plus le repo sur GitHub)
Qui c'est la conne qui a delete le repo sur GitHub? C'EST MOIIIII
This commit is contained in:
@@ -1,25 +1,118 @@
|
||||
const { Events, MessageFlags } = require('discord.js');
|
||||
const { Events, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, MessageFlags } = require('discord.js');
|
||||
const chalk = require('chalk');
|
||||
|
||||
module.exports = {
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// --- 1. GESTION DES MODALS (Soumission) ---
|
||||
if (interaction.isModalSubmit()) {
|
||||
const ticketModule = require('../commands/ticket/ticket.js');
|
||||
|
||||
// 1.A - Création de Ticket (Support, Plainte, etc.)
|
||||
if (interaction.customId.startsWith('ticket_create_modal_')) {
|
||||
// On récupère le type depuis l'ID (ex: ticket_create_modal_Support)
|
||||
const type = interaction.customId.replace('ticket_create_modal_', '');
|
||||
await ticketModule.handleCreate(interaction, type);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1.B - Candidature Spécifique
|
||||
if (interaction.customId === 'candidature_modal') {
|
||||
await ticketModule.handleCandidatureModalSubmit(interaction);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1.C - Raison Fermeture
|
||||
if (interaction.customId === 'ticket_close_reason_modal') {
|
||||
await ticketModule.handleCloseModal(interaction);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1.D - Raison Réouverture
|
||||
if (interaction.customId === 'ticket_reopen_modal') {
|
||||
await ticketModule.handleReopenModal(interaction);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1.E - Raison Suppression
|
||||
if (interaction.customId === 'ticket_delete_modal') {
|
||||
await ticketModule.handleDeleteModal(interaction);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// --- 2. GESTION DES BOUTONS (Ouverture des Modals) ---
|
||||
if (interaction.isButton()) {
|
||||
const ticketModule = require('../commands/ticket/ticket.js');
|
||||
|
||||
// 2.A - Bouton Création : On ouvre un MODAL pour tout le monde
|
||||
if (interaction.customId.startsWith('ticket_create_')) {
|
||||
|
||||
// Cas Spécial : Candidature (Déjà géré avec ses questions spécifiques)
|
||||
if (interaction.customId === 'ticket_create_candidature') {
|
||||
const questions = require('../commands/ticket/ticket.js').CANDIDATURE_QUESTIONS;
|
||||
const modal = new ModalBuilder().setCustomId('candidature_modal').setTitle('Recrutement Staff');
|
||||
for(let i=0; i<Math.min(questions.length,5); i++) {
|
||||
const input = new TextInputBuilder().setCustomId(`cand_q${i+1}`).setLabel(questions[i].substring(0,45)).setStyle(TextInputStyle.Paragraph).setRequired(true);
|
||||
modal.addComponents(new ActionRowBuilder().addComponents(input));
|
||||
}
|
||||
await interaction.showModal(modal);
|
||||
return;
|
||||
}
|
||||
|
||||
// Cas Général (Support, Plainte, etc.): Modal simple "Sujet"
|
||||
// On extrait le type du bouton (ex: ticket_create_support -> support)
|
||||
let typeKey = interaction.customId.replace('ticket_create_', '');
|
||||
// On remet en joli format (support -> Support, plainte_staff -> Plainte Staff)
|
||||
const typeMapping = {
|
||||
'support': 'Support',
|
||||
'plainte': 'Plainte',
|
||||
'plainte_staff': 'Plainte Staff',
|
||||
'probleme_technique': 'Problème Technique'
|
||||
};
|
||||
const prettyType = typeMapping[typeKey] || 'Support';
|
||||
|
||||
// On passe le type dans l'ID du modal pour le récupérer au submit
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId(`ticket_create_modal_${prettyType}`)
|
||||
.setTitle(`Nouveau ticket : ${prettyType}`);
|
||||
|
||||
const subjectInput = new TextInputBuilder()
|
||||
.setCustomId('ticket_subject')
|
||||
.setLabel("Sujet / Raison de la demande")
|
||||
.setStyle(TextInputStyle.Paragraph)
|
||||
.setRequired(true)
|
||||
.setMaxLength(1000)
|
||||
.setPlaceholder("Décrivez brièvement votre problème...");
|
||||
|
||||
modal.addComponents(new ActionRowBuilder().addComponents(subjectInput));
|
||||
await interaction.showModal(modal);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2.B - Autres actions (Fermer, Réouvrir, etc.)
|
||||
if (interaction.customId.startsWith('ticket_close_')) return await ticketModule.handleClose(interaction);
|
||||
if (interaction.customId.startsWith('ticket_delete_')) return await ticketModule.handleDelete(interaction);
|
||||
if (interaction.customId.startsWith('ticket_reopen_')) return await ticketModule.handleReopen(interaction);
|
||||
if (interaction.customId.startsWith('ticket_claim_')) return await ticketModule.handleClaim(interaction);
|
||||
}
|
||||
|
||||
// --- 3. COMMANDES SLASH ---
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
if (!command) {
|
||||
console.error(chalk.red(`Aucune commande correspondant à ${interaction.commandName} n'a été trouvée.`));
|
||||
return;
|
||||
}
|
||||
await command.execute(interaction);
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error(chalk.red(`Erreur lors de l'exécution d'une interaction :`), error);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
await interaction.followUp({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
|
||||
await interaction.followUp({ content: 'Une erreur est survenue lors de l\'exécution de cette interaction !', flags: MessageFlags.Ephemeral });
|
||||
} else {
|
||||
await interaction.reply({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
|
||||
await interaction.reply({ content: 'Une erreur est survenue lors de l\'exécution de cette interaction !', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user