diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..92f97e7 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "es5" +} diff --git a/SlashCommand/general/help.js b/SlashCommand/general/help.js index 3353930..4fcdd18 100644 --- a/SlashCommand/general/help.js +++ b/SlashCommand/general/help.js @@ -1,32 +1,35 @@ -const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() - .setName("help") - .setDescription("Affiche la liste des commandes disponibles"), + .setName('help') + .setDescription('Affiche la liste des commandes disponibles'), async execute(interaction, client) { const globalCommands = await client.application.commands.fetch(); - const commandList = globalCommands.map( - cmd => ` — ${cmd.description || "Pas de description"}` - ).join("\n"); + const commandList = globalCommands + .map( + (cmd) => + ` — ${cmd.description || 'Pas de description'}` + ) + .join('\n'); const embed = new EmbedBuilder() - .setTitle("📖 Aide du bot") + .setTitle('📖 Aide du bot') .setDescription( commandList.length > 0 - ? "Voici la liste des commandes disponibles :\n\n" + commandList - : "❌ Aucune commande trouvée." + ? 'Voici la liste des commandes disponibles :\n\n' + commandList + : '❌ Aucune commande trouvée.' ) .setColor(0x5e99ff) .setThumbnail(client.user.displayAvatarURL()) .setFooter({ text: `QuantumCraft Studios • Demandé par ${interaction.user.tag}`, - iconURL: interaction.user.displayAvatarURL() + iconURL: interaction.user.displayAvatarURL(), }) .setTimestamp(); await interaction.reply({ embeds: [embed], flags: 64 }); - } -}; \ No newline at end of file + }, +}; diff --git a/SlashCommand/general/ping.js b/SlashCommand/general/ping.js index 13d9e79..079081a 100644 --- a/SlashCommand/general/ping.js +++ b/SlashCommand/general/ping.js @@ -1,11 +1,11 @@ -const { SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() - .setName("ping") - .setDescription("Répond avec Pong !"), + .setName('ping') + .setDescription('Répond avec Pong !'), async execute(interaction) { - await interaction.reply("🏓 Pong !"); - } -}; \ No newline at end of file + await interaction.reply('🏓 Pong !'); + }, +}; diff --git a/SlashCommand/tickets/add.js b/SlashCommand/tickets/add.js index 6d3e741..0704ad2 100644 --- a/SlashCommand/tickets/add.js +++ b/SlashCommand/tickets/add.js @@ -1,13 +1,14 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { config, lang } = require("../../handlers/configLoader"); -const { getTicketByChannel } = require("../../handlers/database"); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { config, lang } = require('../../handlers/configLoader'); +const { getTicketByChannel } = require('../../handlers/database'); module.exports = { data: new SlashCommandBuilder() - .setName("add") + .setName('add') .setDescription(lang.commands.add.description) - .addUserOption(option => - option.setName("utilisateur") + .addUserOption((option) => + option + .setName('utilisateur') .setDescription("L'utilisateur à ajouter au ticket") .setRequired(true) ), @@ -15,13 +16,16 @@ module.exports = { async execute(interaction) { const member = interaction.member; - const staffRoles = (Array.isArray(config.staffRoles) ? config.staffRoles : [config.staffRole || config.staffRoles]) - .filter(r => r && r.trim() !== ""); + const staffRoles = ( + Array.isArray(config.staffRoles) + ? config.staffRoles + : [config.staffRole || config.staffRoles] + ).filter((r) => r && r.trim() !== ''); - if (!staffRoles.some(roleId => member.roles.cache.has(roleId))) { + if (!staffRoles.some((roleId) => member.roles.cache.has(roleId))) { return interaction.reply({ content: lang.permissions.staff_only, - flags: 64 + flags: 64, }); } @@ -29,17 +33,21 @@ module.exports = { if (!ticket) { return interaction.reply({ content: lang.ticket.not_in_ticket, - flags: 64 + flags: 64, }); } - const userToAdd = interaction.options.getUser("utilisateur"); + const userToAdd = interaction.options.getUser('utilisateur'); - const existingOverwrite = interaction.channel.permissionOverwrites.cache.get(userToAdd.id); - if (existingOverwrite && existingOverwrite.allow.has(PermissionFlagsBits.ViewChannel)) { + const existingOverwrite = + interaction.channel.permissionOverwrites.cache.get(userToAdd.id); + if ( + existingOverwrite && + existingOverwrite.allow.has(PermissionFlagsBits.ViewChannel) + ) { return interaction.reply({ - content: lang.commands.add.already_added.replace("{user}", userToAdd), - flags: 64 + content: lang.commands.add.already_added.replace('{user}', userToAdd), + flags: 64, }); } @@ -51,20 +59,19 @@ module.exports = { }); await interaction.reply({ - content: lang.commands.add.success.replace("{user}", userToAdd), - flags: 64 + content: lang.commands.add.success.replace('{user}', userToAdd), + flags: 64, }); await interaction.channel.send( - lang.commands.add.welcome.replace("{user}", userToAdd) + lang.commands.add.welcome.replace('{user}', userToAdd) ); - } catch (err) { console.error(err); await interaction.reply({ content: lang.commands.add.error, - flags: 64 + flags: 64, }); } - } -}; \ No newline at end of file + }, +}; diff --git a/SlashCommand/tickets/alert.js b/SlashCommand/tickets/alert.js index 62196c7..b4e67c8 100644 --- a/SlashCommand/tickets/alert.js +++ b/SlashCommand/tickets/alert.js @@ -3,16 +3,16 @@ const { EmbedBuilder, ButtonBuilder, ButtonStyle, - ActionRowBuilder -} = require("discord.js"); -const { config, lang } = require("../../handlers/configLoader"); -const { getTicketByChannel, closeTicket } = require("../../handlers/database"); -const { scheduleTicketClosure } = require("../../handlers/alertManager"); -const ms = require("ms"); + ActionRowBuilder, +} = require('discord.js'); +const { config, lang } = require('../../handlers/configLoader'); +const { getTicketByChannel, closeTicket } = require('../../handlers/database'); +const { scheduleTicketClosure } = require('../../handlers/alertManager'); +const ms = require('ms'); module.exports = { data: new SlashCommandBuilder() - .setName("alert") + .setName('alert') .setDescription(lang.commands.alert.description), async execute(interaction, client) { @@ -20,38 +20,42 @@ module.exports = { if (!ticket) { return interaction.reply({ content: lang.ticket.not_in_ticket, - flags: 64 + flags: 64, }); } const member = interaction.member; - const isStaff = config.staffRoles.some(roleId => member.roles.cache.has(roleId)); + const isStaff = config.staffRoles.some((roleId) => + member.roles.cache.has(roleId) + ); if (!isStaff) { return interaction.reply({ content: lang.permissions.staff_only, - flags: 64 + flags: 64, }); } - const alertDuration = ms(config.TicketAlert.Time || "1h"); + const alertDuration = ms(config.TicketAlert.Time || '1h'); const now = Date.now(); const inactiveTime = ``; // === Boutons === const closeBtn = new ButtonBuilder() - .setCustomId("closeTicket") - .setLabel(lang.commands.alert.close_now_label || "🔒 Fermer maintenant") + .setCustomId('closeTicket') + .setLabel(lang.commands.alert.close_now_label || '🔒 Fermer maintenant') .setStyle(ButtonStyle.Danger); const cancelBtn = new ButtonBuilder() - .setCustomId("cancelClosure") - .setLabel(lang.commands.alert.cancel_label || "🚫 Annuler la fermeture") + .setCustomId('cancelClosure') + .setLabel(lang.commands.alert.cancel_label || '🚫 Annuler la fermeture') .setStyle(ButtonStyle.Secondary); const linkBtn = new ButtonBuilder() - .setLabel("🔗 Voir le ticket") + .setLabel('🔗 Voir le ticket') .setStyle(ButtonStyle.Link) - .setURL(`https://discord.com/channels/${interaction.guild.id}/${interaction.channel.id}`); + .setURL( + `https://discord.com/channels/${interaction.guild.id}/${interaction.channel.id}` + ); const row1 = new ActionRowBuilder().addComponents(closeBtn, cancelBtn); const row2 = new ActionRowBuilder().addComponents(linkBtn); @@ -61,8 +65,11 @@ module.exports = { .setColor(0xe67e22) .setDescription( lang.commands.alert.sent - .replace("{time}", ``) - .replace("{inactive-time}", inactiveTime) + .replace( + '{time}', + `` + ) + .replace('{inactive-time}', inactiveTime) ) .setTimestamp(); @@ -70,21 +77,26 @@ module.exports = { .setColor(0xe67e22) .setDescription( lang.commands.alert.sent - .replace("{time}", ``) - .replace("{inactive-time}", inactiveTime) + .replace( + '{time}', + `` + ) + .replace('{inactive-time}', inactiveTime) ) .setTimestamp(); // === Envoi DM si activé === if (config.TicketAlert?.DMUser && ticket.userId) { - const ticketCreator = await client.users.fetch(ticket.userId).catch(() => null); + const ticketCreator = await client.users + .fetch(ticket.userId) + .catch(() => null); if (ticketCreator) { try { await ticketCreator.send({ embeds: [dmEmbed], components: [row2] }); } catch { await interaction.reply({ content: lang.commands.alert.dm_unreachable, - flags: 64 + flags: 64, }); } } @@ -94,7 +106,7 @@ module.exports = { await interaction.reply({ content: ticket.userId ? `<@${ticket.userId}>` : null, embeds: [alertEmbed], - components: [row1] + components: [row1], }); // === Planification de la fermeture auto === @@ -102,5 +114,5 @@ module.exports = { closeTicket(interaction.channel.id); await interaction.channel.delete().catch(() => {}); }); - } + }, }; diff --git a/SlashCommand/tickets/close.js b/SlashCommand/tickets/close.js index 948da7b..2554db2 100644 --- a/SlashCommand/tickets/close.js +++ b/SlashCommand/tickets/close.js @@ -1,17 +1,24 @@ -const { SlashCommandBuilder, EmbedBuilder, MessageFlags } = require("discord.js"); -const { getTicketByChannel, closeTicket } = require("../../handlers/database"); -const { config, lang } = require("../../handlers/configLoader"); +const { + SlashCommandBuilder, + EmbedBuilder, + MessageFlags, +} = require('discord.js'); +const { getTicketByChannel, closeTicket } = require('../../handlers/database'); +const { config, lang } = require('../../handlers/configLoader'); module.exports = { data: new SlashCommandBuilder() - .setName("close") - .setDescription("Fermer un ticket"), + .setName('close') + .setDescription('Fermer un ticket'), async execute(interaction) { const ticket = getTicketByChannel(interaction.channel.id); if (!ticket) { - return interaction.reply({ content: lang.ticket.not_in_ticket, flags: MessageFlags.Ephemeral }); + return interaction.reply({ + content: lang.ticket.not_in_ticket, + flags: MessageFlags.Ephemeral, + }); } closeTicket(interaction.channel.id); @@ -19,13 +26,19 @@ module.exports = { await interaction.reply(lang.ticket.closing); // Log fermeture - const logChannel = await interaction.client.channels.fetch(config.logsChannel).catch(() => null); + const logChannel = await interaction.client.channels + .fetch(config.logsChannel) + .catch(() => null); if (logChannel) { const embed = new EmbedBuilder() - .setTitle("🔒 Ticket fermé") + .setTitle('🔒 Ticket fermé') .addFields( - { name: "Salon", value: `${interaction.channel.name}`, inline: true }, - { name: "Fermé par", value: `${interaction.user.tag} (${interaction.user.id})`, inline: true } + { name: 'Salon', value: `${interaction.channel.name}`, inline: true }, + { + name: 'Fermé par', + value: `${interaction.user.tag} (${interaction.user.id})`, + inline: true, + } ) .setColor(0xe74c3c) .setTimestamp(); @@ -35,5 +48,5 @@ module.exports = { setTimeout(() => { interaction.channel.delete().catch(() => {}); }, 5000); - } + }, }; diff --git a/SlashCommand/tickets/remove.js b/SlashCommand/tickets/remove.js index da4903b..b5e3952 100644 --- a/SlashCommand/tickets/remove.js +++ b/SlashCommand/tickets/remove.js @@ -1,13 +1,14 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { config, lang } = require("../../handlers/configLoader"); -const { getTicketByChannel } = require("../../handlers/database"); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { config, lang } = require('../../handlers/configLoader'); +const { getTicketByChannel } = require('../../handlers/database'); module.exports = { data: new SlashCommandBuilder() - .setName("remove") + .setName('remove') .setDescription(lang.commands.remove.description) - .addUserOption(option => - option.setName("utilisateur") + .addUserOption((option) => + option + .setName('utilisateur') .setDescription("L'utilisateur à retirer du ticket") .setRequired(true) ), @@ -15,13 +16,16 @@ module.exports = { async execute(interaction) { const member = interaction.member; - const staffRoles = (Array.isArray(config.staffRoles) ? config.staffRoles : [config.staffRole || config.staffRoles]) - .filter(r => r && r.trim() !== ""); + const staffRoles = ( + Array.isArray(config.staffRoles) + ? config.staffRoles + : [config.staffRole || config.staffRoles] + ).filter((r) => r && r.trim() !== ''); - if (!staffRoles.some(roleId => member.roles.cache.has(roleId))) { + if (!staffRoles.some((roleId) => member.roles.cache.has(roleId))) { return interaction.reply({ content: lang.permissions.staff_only, - flags: 64 + flags: 64, }); } @@ -29,17 +33,24 @@ module.exports = { if (!ticket) { return interaction.reply({ content: lang.ticket.not_in_ticket, - flags: 64 + flags: 64, }); } - const userToRemove = interaction.options.getUser("utilisateur"); + const userToRemove = interaction.options.getUser('utilisateur'); - const existingOverwrite = interaction.channel.permissionOverwrites.cache.get(userToRemove.id); - if (!existingOverwrite || !existingOverwrite.allow.has(PermissionFlagsBits.ViewChannel)) { + const existingOverwrite = + interaction.channel.permissionOverwrites.cache.get(userToRemove.id); + if ( + !existingOverwrite || + !existingOverwrite.allow.has(PermissionFlagsBits.ViewChannel) + ) { return interaction.reply({ - content: lang.commands.remove.not_in_ticket.replace("{user}", userToRemove), - flags: 64 + content: lang.commands.remove.not_in_ticket.replace( + '{user}', + userToRemove + ), + flags: 64, }); } @@ -51,20 +62,19 @@ module.exports = { }); await interaction.reply({ - content: lang.commands.remove.success.replace("{user}", userToRemove), - flags: 64 + content: lang.commands.remove.success.replace('{user}', userToRemove), + flags: 64, }); await interaction.channel.send( - lang.commands.remove.goodbye.replace("{user}", userToRemove) + lang.commands.remove.goodbye.replace('{user}', userToRemove) ); - } catch (err) { console.error(err); await interaction.reply({ content: lang.commands.remove.error, - flags: 64 + flags: 64, }); } - } -}; \ No newline at end of file + }, +}; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..f313e25 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,31 @@ +import js from "@eslint/js"; +import prettierConfig from "eslint-config-prettier"; +import prettier from "eslint-plugin-prettier"; +import globals from "globals"; + +export default [ + { + ignores: ["eslint.config.mjs"], + }, + js.configs.recommended, + { + files: ["**/*.{js,mjs,cjs}"], + languageOptions: { + ecmaVersion: "latest", + sourceType: "commonjs", + globals: globals.node, + }, + plugins: { + prettier, + }, + rules: { + "prettier/prettier": "error", + "no-console": "off", + "no-empty-function": "off", + "no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], + "prefer-const": "error", + "no-var": "error" + }, + }, + prettierConfig, +]; \ No newline at end of file diff --git a/events/clients/deploy-commands.js b/events/clients/deploy-commands.js index 8ece509..b845412 100644 --- a/events/clients/deploy-commands.js +++ b/events/clients/deploy-commands.js @@ -1,23 +1,28 @@ -const { REST, Routes } = require("discord.js"); -const { getCommandsJSON } = require("../../handlers/commandHandler"); -const logger = require("../../handlers/logger"); +const { REST, Routes } = require('discord.js'); +const { getCommandsJSON } = require('../../handlers/commandHandler'); +const logger = require('../../handlers/logger'); module.exports = { - name: "clientReady", + name: 'clientReady', once: true, async execute(client) { const commands = getCommandsJSON(); - const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN); + const rest = new REST({ version: '10' }).setToken( + process.env.DISCORD_TOKEN + ); try { - logger.info("⏳ Déploiement des slash commands..."); - await rest.put( - Routes.applicationCommands(process.env.CLIENT_ID), - { body: commands } + logger.info('⏳ Déploiement des slash commands...'); + await rest.put(Routes.applicationCommands(process.env.CLIENT_ID), { + body: commands, + }); + logger.success( + `✅ ${commands.length} slash commands déployées avec succès !` ); - logger.success(`✅ ${commands.length} slash commands déployées avec succès !`); } catch (error) { - logger.error(`❌ Erreur lors du déploiement des commandes : ${error.message}`); + logger.error( + `❌ Erreur lors du déploiement des commandes : ${error.message}` + ); } - } -}; \ No newline at end of file + }, +}; diff --git a/events/clients/panel.js b/events/clients/panel.js index 9d41057..3d0da5e 100644 --- a/events/clients/panel.js +++ b/events/clients/panel.js @@ -3,25 +3,25 @@ const { ButtonBuilder, ButtonStyle, EmbedBuilder, - StringSelectMenuBuilder -} = require("discord.js"); -const { config } = require("../../handlers/configLoader"); -const logger = require("../../handlers/logger"); + StringSelectMenuBuilder, +} = require('discord.js'); +const { config } = require('../../handlers/configLoader'); +const logger = require('../../handlers/logger'); function parseColor(raw) { - if (!raw) return 0x5865F2; - if (typeof raw === "number") return raw; - if (typeof raw === "string") { - if (raw.startsWith("0x")) return parseInt(raw, 16); - if (raw.startsWith("#")) return parseInt(raw.slice(1), 16); + if (!raw) return 0x5865f2; + if (typeof raw === 'number') return raw; + if (typeof raw === 'string') { + if (raw.startsWith('0x')) return parseInt(raw, 16); + if (raw.startsWith('#')) return parseInt(raw.slice(1), 16); const asInt = parseInt(raw); if (!isNaN(asInt)) return asInt; } - return 0x5865F2; + return 0x5865f2; } module.exports = { - name: "clientReady", + name: 'clientReady', once: true, async execute(client) { const panelConfig = config.TicketPanel.Panel; @@ -32,34 +32,40 @@ module.exports = { const channel = await client.channels.fetch(channelId).catch(() => null); if (!channel) { - return logger.error("❌ Impossible de trouver le salon défini pour le panel de ticket."); + return logger.error( + '❌ Impossible de trouver le salon défini pour le panel de ticket.' + ); } // === Embed principal === const embed = new EmbedBuilder() - .setTitle(panelConfig.Embed.Title || "") - .setDescription(panelConfig.Embed.Description || "") + .setTitle(panelConfig.Embed.Title || '') + .setDescription(panelConfig.Embed.Description || '') .setColor(parseColor(panelConfig.Embed.Color)); - if (panelConfig.Embed.PanelImage) embed.setImage(panelConfig.Embed.PanelImage); - if (panelConfig.Embed.CustomThumbnailURL) embed.setThumbnail(panelConfig.Embed.CustomThumbnailURL); + if (panelConfig.Embed.PanelImage) + embed.setImage(panelConfig.Embed.PanelImage); + if (panelConfig.Embed.CustomThumbnailURL) + embed.setThumbnail(panelConfig.Embed.CustomThumbnailURL); if (panelConfig.Embed.Timestamp) embed.setTimestamp(); if (panelConfig.Embed.Footer && panelConfig.Embed.Footer.Enabled) { embed.setFooter({ - text: panelConfig.Embed.Footer.Text || "", - iconURL: panelConfig.Embed.Footer.CustomIconURL || null + text: panelConfig.Embed.Footer.Text || '', + iconURL: panelConfig.Embed.Footer.CustomIconURL || null, }); } let row; // === Gestion des interactions === - if (panelConfig.InteractionType === "select" && panelConfig.SelectMenu) { + if (panelConfig.InteractionType === 'select' && panelConfig.SelectMenu) { // 📌 Mode Select Menu const menu = new StringSelectMenuBuilder() - .setCustomId("ticket_select") - .setPlaceholder(panelConfig.SelectMenu.Placeholder || "Choisis une option..."); + .setCustomId('ticket_select') + .setPlaceholder( + panelConfig.SelectMenu.Placeholder || 'Choisis une option...' + ); for (const opt of panelConfig.SelectMenu.Options) { const option = { @@ -74,7 +80,6 @@ module.exports = { } row = new ActionRowBuilder().addComponents(menu); - } else { // 📌 Mode Boutons par défaut row = new ActionRowBuilder(); @@ -95,5 +100,5 @@ module.exports = { await channel.send({ embeds: [embed], components: [row] }); logger.success(`✅ Panel "${panelConfig.Name}" envoyé avec succès !`); - } -}; \ No newline at end of file + }, +}; diff --git a/events/clients/ready.js b/events/clients/ready.js index bf78412..e43871a 100644 --- a/events/clients/ready.js +++ b/events/clients/ready.js @@ -1,9 +1,9 @@ -const logger = require("../../handlers/logger"); +const logger = require('../../handlers/logger'); module.exports = { - name: "clientReady", + name: 'clientReady', once: true, execute(client) { logger.success(`Connecté en tant que ${client.user.tag}`); - } -}; \ No newline at end of file + }, +}; diff --git a/events/guilds/interactionCreate.js b/events/guilds/interactionCreate.js index c3c4b33..f290e8f 100644 --- a/events/guilds/interactionCreate.js +++ b/events/guilds/interactionCreate.js @@ -1,5 +1,5 @@ module.exports = { - name: "interactionCreate", + name: 'interactionCreate', once: false, async execute(interaction, client) { try { @@ -12,10 +12,16 @@ module.exports = { // Buttons if (interaction.isButton()) { for (const button of client.buttons.values()) { - if (typeof button.id === "string" && button.id === interaction.customId) { + if ( + typeof button.id === 'string' && + button.id === interaction.customId + ) { return button.execute(interaction, client); } - if (button.id instanceof RegExp && button.id.test(interaction.customId)) { + if ( + button.id instanceof RegExp && + button.id.test(interaction.customId) + ) { return button.execute(interaction, client); } } @@ -24,10 +30,16 @@ module.exports = { // Modals if (interaction.isModalSubmit()) { for (const modal of client.modals.values()) { - if (typeof modal.id === "string" && modal.id === interaction.customId) { + if ( + typeof modal.id === 'string' && + modal.id === interaction.customId + ) { return modal.execute(interaction, client); } - if (modal.id instanceof RegExp && modal.id.test(interaction.customId)) { + if ( + modal.id instanceof RegExp && + modal.id.test(interaction.customId) + ) { return modal.execute(interaction, client); } } @@ -41,7 +53,7 @@ module.exports = { interaction.isChannelSelectMenu() ) { for (const menu of client.menus.values()) { - if (typeof menu.id === "string" && menu.id === interaction.customId) { + if (typeof menu.id === 'string' && menu.id === interaction.customId) { return menu.execute(interaction, client); } if (menu.id instanceof RegExp && menu.id.test(interaction.customId)) { @@ -52,10 +64,16 @@ module.exports = { } catch (error) { console.error(error); if (interaction.replied || interaction.deferred) { - await interaction.followUp({ content: "❌ Une erreur est survenue.", flags: 64 }); + await interaction.followUp({ + content: '❌ Une erreur est survenue.', + flags: 64, + }); } else { - await interaction.reply({ content: "❌ Une erreur est survenue.", flags: 64 }); + await interaction.reply({ + content: '❌ Une erreur est survenue.', + flags: 64, + }); } } - } -}; \ No newline at end of file + }, +}; diff --git a/events/guilds/messageCreate.js b/events/guilds/messageCreate.js index bc12bc7..a0e7644 100644 --- a/events/guilds/messageCreate.js +++ b/events/guilds/messageCreate.js @@ -1,10 +1,10 @@ -const { getTicketByChannel } = require("../../handlers/database"); -const { cancelTicketClosure } = require("../../handlers/alertManager"); -const { lang } = require("../../handlers/configLoader"); -const { EmbedBuilder } = require("discord.js"); +const { getTicketByChannel } = require('../../handlers/database'); +const { cancelTicketClosure } = require('../../handlers/alertManager'); +const { lang } = require('../../handlers/configLoader'); +const { EmbedBuilder } = require('discord.js'); module.exports = { - name: "messageCreate", + name: 'messageCreate', once: false, async execute(message) { if (message.author.bot) return; @@ -22,5 +22,5 @@ module.exports = { await message.channel.send({ embeds: [embed] }); } } - } + }, }; diff --git a/handlers/alertManager.js b/handlers/alertManager.js index 252f401..cd20060 100644 --- a/handlers/alertManager.js +++ b/handlers/alertManager.js @@ -1,6 +1,5 @@ const activeAlerts = new Map(); - function scheduleTicketClosure(channel, duration, closeFn) { if (activeAlerts.has(channel.id)) { clearTimeout(activeAlerts.get(channel.id)); @@ -24,4 +23,4 @@ function cancelTicketClosure(channelId) { return false; } -module.exports = { scheduleTicketClosure, cancelTicketClosure }; \ No newline at end of file +module.exports = { scheduleTicketClosure, cancelTicketClosure }; diff --git a/handlers/buttonHandler.js b/handlers/buttonHandler.js index 7f0fa12..071679f 100644 --- a/handlers/buttonHandler.js +++ b/handlers/buttonHandler.js @@ -1,14 +1,16 @@ -const fs = require("fs"); -const path = require("path"); -const { Collection } = require("discord.js"); +const fs = require('fs'); +const path = require('path'); +const { Collection } = require('discord.js'); function loadButtons(client) { - const interactionsPath = path.join(__dirname, "../interactions"); + const interactionsPath = path.join(__dirname, '../interactions'); client.buttons = new Collection(); if (!fs.existsSync(interactionsPath)) return client.buttons; - const files = fs.readdirSync(interactionsPath).filter(f => f.endsWith(".js")); + const files = fs + .readdirSync(interactionsPath) + .filter((f) => f.endsWith('.js')); for (const file of files) { const button = require(path.join(interactionsPath, file)); @@ -33,4 +35,4 @@ async function handleButton(interaction, client) { } } -module.exports = { loadButtons, handleButton }; \ No newline at end of file +module.exports = { loadButtons, handleButton }; diff --git a/handlers/commandHandler.js b/handlers/commandHandler.js index 5c4d592..8fb574d 100644 --- a/handlers/commandHandler.js +++ b/handlers/commandHandler.js @@ -1,6 +1,6 @@ -const fs = require("fs"); -const path = require("path"); -const { Collection } = require("discord.js"); +const fs = require('fs'); +const path = require('path'); +const { Collection } = require('discord.js'); function walkCommands(dir, callback) { const files = fs.readdirSync(dir, { withFileTypes: true }); @@ -10,7 +10,7 @@ function walkCommands(dir, callback) { if (file.isDirectory()) { walkCommands(filePath, callback); - } else if (file.name.endsWith(".js")) { + } else if (file.name.endsWith('.js')) { const command = require(filePath); callback(command); } @@ -18,7 +18,7 @@ function walkCommands(dir, callback) { } function loadCommands(client) { - const commandsPath = path.join(__dirname, "../SlashCommand"); + const commandsPath = path.join(__dirname, '../SlashCommand'); client.commands = new Collection(); walkCommands(commandsPath, (command) => { @@ -29,7 +29,7 @@ function loadCommands(client) { } function getCommandsJSON() { - const commandsPath = path.join(__dirname, "../SlashCommand"); + const commandsPath = path.join(__dirname, '../SlashCommand'); const commands = []; walkCommands(commandsPath, (command) => { @@ -39,4 +39,4 @@ function getCommandsJSON() { return commands; } -module.exports = { loadCommands, getCommandsJSON }; \ No newline at end of file +module.exports = { loadCommands, getCommandsJSON }; diff --git a/handlers/configLoader.js b/handlers/configLoader.js index d960ecb..a074375 100644 --- a/handlers/configLoader.js +++ b/handlers/configLoader.js @@ -1,14 +1,14 @@ -const fs = require("fs"); -const path = require("path"); -const YAML = require("yaml"); +const fs = require('fs'); +const path = require('path'); +const YAML = require('yaml'); function loadYAML(file) { - const filePath = path.join(__dirname, "..", file); - const content = fs.readFileSync(filePath, "utf8"); + const filePath = path.join(__dirname, '..', file); + const content = fs.readFileSync(filePath, 'utf8'); return YAML.parse(content); } -const config = loadYAML("config.yml"); -const lang = loadYAML("lang.yml"); +const config = loadYAML('config.yml'); +const lang = loadYAML('lang.yml'); -module.exports = { config, lang }; \ No newline at end of file +module.exports = { config, lang }; diff --git a/handlers/database.js b/handlers/database.js index 8fbe7b3..2ddc082 100644 --- a/handlers/database.js +++ b/handlers/database.js @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const initSqlJs = require("sql.js"); +const fs = require('fs'); +const path = require('path'); +const initSqlJs = require('sql.js'); -const dbPath = path.join(__dirname, "../tickets.db"); +const dbPath = path.join(__dirname, '../tickets.db'); let db; @@ -56,4 +56,4 @@ function closeTicket(channelId) { saveDB(); } -module.exports = { initDB, createTicket, getTicketByChannel, closeTicket }; \ No newline at end of file +module.exports = { initDB, createTicket, getTicketByChannel, closeTicket }; diff --git a/handlers/eventHandler.js b/handlers/eventHandler.js index 85cb94f..6f1656e 100644 --- a/handlers/eventHandler.js +++ b/handlers/eventHandler.js @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); +const fs = require('fs'); +const path = require('path'); function loadEvents(client) { - const eventsPath = path.join(__dirname, "../events"); + const eventsPath = path.join(__dirname, '../events'); function walk(dir) { const files = fs.readdirSync(dir, { withFileTypes: true }); @@ -12,7 +12,7 @@ function loadEvents(client) { if (file.isDirectory()) { walk(filePath); - } else if (file.name.endsWith(".js")) { + } else if (file.name.endsWith('.js')) { const event = require(filePath); if (event.once) { @@ -27,4 +27,4 @@ function loadEvents(client) { walk(eventsPath); } -module.exports = { loadEvents }; \ No newline at end of file +module.exports = { loadEvents }; diff --git a/handlers/logger.js b/handlers/logger.js index dce5727..e3a2af5 100644 --- a/handlers/logger.js +++ b/handlers/logger.js @@ -1,27 +1,27 @@ -const chalk = require("chalk"); +const chalk = require('chalk'); function timestamp() { - return chalk.gray(`[${new Date().toLocaleTimeString("fr-FR")}]`); + return chalk.gray(`[${new Date().toLocaleTimeString('fr-FR')}]`); } const logger = { info: (msg) => { - console.log(`${timestamp()} ${chalk.blue("[INFO]")} ${msg}`); + console.log(`${timestamp()} ${chalk.blue('[INFO]')} ${msg}`); }, success: (msg) => { - console.log(`${timestamp()} ${chalk.green("[SUCCESS]")} ${msg}`); + console.log(`${timestamp()} ${chalk.green('[SUCCESS]')} ${msg}`); }, warn: (msg) => { - console.warn(`${timestamp()} ${chalk.yellow("[WARN]")} ${msg}`); + console.warn(`${timestamp()} ${chalk.yellow('[WARN]')} ${msg}`); }, error: (msg) => { - console.error(`${timestamp()} ${chalk.red("[ERROR]")} ${msg}`); + console.error(`${timestamp()} ${chalk.red('[ERROR]')} ${msg}`); }, debug: (msg) => { - if (process.env.DEBUG === "true") { - console.log(`${timestamp()} ${chalk.magenta("[DEBUG]")} ${msg}`); + if (process.env.DEBUG === 'true') { + console.log(`${timestamp()} ${chalk.magenta('[DEBUG]')} ${msg}`); } - } + }, }; -module.exports = logger; \ No newline at end of file +module.exports = logger; diff --git a/handlers/menuHandler.js b/handlers/menuHandler.js index 91c7b2c..7c13026 100644 --- a/handlers/menuHandler.js +++ b/handlers/menuHandler.js @@ -1,14 +1,16 @@ -const fs = require("fs"); -const path = require("path"); -const { Collection } = require("discord.js"); +const fs = require('fs'); +const path = require('path'); +const { Collection } = require('discord.js'); function loadMenus(client) { - const interactionsPath = path.join(__dirname, "../interactions"); + const interactionsPath = path.join(__dirname, '../interactions'); client.menus = new Collection(); if (!fs.existsSync(interactionsPath)) return client.menus; - const files = fs.readdirSync(interactionsPath).filter(f => f.toLowerCase().includes("menu") && f.endsWith(".js")); + const files = fs + .readdirSync(interactionsPath) + .filter((f) => f.toLowerCase().includes('menu') && f.endsWith('.js')); for (const file of files) { const menu = require(path.join(interactionsPath, file)); @@ -20,7 +22,7 @@ function loadMenus(client) { async function handleMenu(interaction, client) { for (const menu of client.menus.values()) { - if (typeof menu.id === "string" && menu.id === interaction.customId) { + if (typeof menu.id === 'string' && menu.id === interaction.customId) { return menu.execute(interaction, client); } if (menu.id instanceof RegExp && menu.id.test(interaction.customId)) { @@ -29,4 +31,4 @@ async function handleMenu(interaction, client) { } } -module.exports = { loadMenus, handleMenu }; \ No newline at end of file +module.exports = { loadMenus, handleMenu }; diff --git a/handlers/modalHandler.js b/handlers/modalHandler.js index c7a4eee..fb3c2f3 100644 --- a/handlers/modalHandler.js +++ b/handlers/modalHandler.js @@ -1,13 +1,15 @@ -const fs = require("fs"); -const path = require("path"); -const { Collection } = require("discord.js"); -const { config } = require("./configLoader"); +const fs = require('fs'); +const path = require('path'); +const { Collection } = require('discord.js'); +const { config } = require('./configLoader'); function loadModals(client) { - const interactionsPath = path.join(__dirname, "../interactions"); + const interactionsPath = path.join(__dirname, '../interactions'); client.modals = new Collection(); - const files = fs.readdirSync(interactionsPath).filter(f => f.toLowerCase().includes("modal") && f.endsWith(".js")); + const files = fs + .readdirSync(interactionsPath) + .filter((f) => f.toLowerCase().includes('modal') && f.endsWith('.js')); for (const file of files) { const modal = require(path.join(interactionsPath, file)); @@ -21,4 +23,4 @@ function getModal(customId) { return config.TicketPanel?.Modals?.[customId] || null; } -module.exports = { loadModals, getModal }; \ No newline at end of file +module.exports = { loadModals, getModal }; diff --git a/index.js b/index.js index cfa8a74..2701a3f 100644 --- a/index.js +++ b/index.js @@ -1,24 +1,38 @@ -const env = require("@dotenvx/dotenvx").config(); -const { Client, GatewayIntentBits } = require("discord.js"); -const { loadEvents } = require("./handlers/eventHandler"); -const { loadCommands } = require("./handlers/commandHandler"); -const { loadButtons } = require("./handlers/buttonHandler"); -const { loadModals } = require("./handlers/modalHandler"); -const { loadMenus } = require("./handlers/menuHandler"); -const { initDB } = require("./handlers/database"); -const logger = require("./handlers/logger"); -const chalk = require("chalk"); +const env = require('@dotenvx/dotenvx').config(); +const { Client, GatewayIntentBits } = require('discord.js'); +const { loadEvents } = require('./handlers/eventHandler'); +const { loadCommands } = require('./handlers/commandHandler'); +const { loadButtons } = require('./handlers/buttonHandler'); +const { loadModals } = require('./handlers/modalHandler'); +const { loadMenus } = require('./handlers/menuHandler'); +const { initDB } = require('./handlers/database'); +const logger = require('./handlers/logger'); +const chalk = require('chalk'); const count = Object.keys(env.parsed || {}).length; -const keys = Object.keys(env.parsed || {}).join(", "); -const colors = [chalk.red, chalk.green, chalk.yellow, chalk.blue, chalk.magenta, chalk.cyan, chalk.white]; -const coloredKeys = Object.keys(env.parsed || {}).map((key, i) => colors[i % colors.length](key)).join(", "); +const keys = Object.keys(env.parsed || {}).join(', '); +const colors = [ + chalk.red, + chalk.green, + chalk.yellow, + chalk.blue, + chalk.magenta, + chalk.cyan, + chalk.white, +]; +const coloredKeys = Object.keys(env.parsed || {}) + .map((key, i) => colors[i % colors.length](key)) + .join(', '); logger.success(`🚀 ${process.env.BOT_START_MESSAGE}`); logger.info(`🔑 Variables .env détectées (${count}) : ${coloredKeys}`); const client = new Client({ - intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + ], }); loadEvents(client); @@ -35,4 +49,4 @@ loadMenus(client); logger.error(`Erreur au démarrage : ${error.message}`); process.exit(1); } -})(); \ No newline at end of file +})(); diff --git a/interactions/cancelClosure.js b/interactions/cancelClosure.js index 0ffc992..d928363 100644 --- a/interactions/cancelClosure.js +++ b/interactions/cancelClosure.js @@ -1,21 +1,23 @@ -const { config, lang } = require("../handlers/configLoader"); +const { config, lang } = require('../handlers/configLoader'); module.exports = { - id: "cancelClosure", + id: 'cancelClosure', async execute(interaction) { const member = interaction.member; - const isStaff = config.staffRoles.some(roleId => member.roles.cache.has(roleId)); + const isStaff = config.staffRoles.some((roleId) => + member.roles.cache.has(roleId) + ); if (!isStaff) { return interaction.reply({ content: lang.permissions.staff_only, - flags: 64 + flags: 64, }); } await interaction.reply({ content: lang.commands.alert.cancelled, - flags: 64 + flags: 64, }); - } + }, }; diff --git a/interactions/closeTicket.js b/interactions/closeTicket.js index 5815b7c..3e8414b 100644 --- a/interactions/closeTicket.js +++ b/interactions/closeTicket.js @@ -1,15 +1,20 @@ -const { PermissionFlagsBits } = require("discord.js"); -const { closeTicket } = require("../handlers/database"); -const { config, lang } = require("../handlers/configLoader"); +const { PermissionFlagsBits } = require('discord.js'); +const { closeTicket } = require('../handlers/database'); +const { config, lang } = require('../handlers/configLoader'); module.exports = { - id: "closeTicket", + id: 'closeTicket', async execute(interaction) { const member = interaction.member; - const isStaff = member.roles.cache.some(role => config.staffRoles.includes(role.id)); + const isStaff = member.roles.cache.some((role) => + config.staffRoles.includes(role.id) + ); if (!isStaff) { - return interaction.reply({ content: lang.permissions.staff_only, flags: 64 }); + return interaction.reply({ + content: lang.permissions.staff_only, + flags: 64, + }); } const channel = interaction.channel; @@ -20,5 +25,5 @@ module.exports = { closeTicket(channel.id); await channel.delete().catch(() => {}); }, 5000); - } + }, }; diff --git a/interactions/ticketButton.js b/interactions/ticketButton.js index cf9b756..5b3c43e 100644 --- a/interactions/ticketButton.js +++ b/interactions/ticketButton.js @@ -4,26 +4,28 @@ const { TextInputStyle, ActionRowBuilder, PermissionFlagsBits, - EmbedBuilder -} = require("discord.js"); -const { getModal } = require("../handlers/modalHandler"); -const { createTicket } = require("../handlers/database"); -const { config } = require("../handlers/configLoader"); + EmbedBuilder, +} = require('discord.js'); +const { getModal } = require('../handlers/modalHandler'); +const { createTicket } = require('../handlers/database'); +const { config } = require('../handlers/configLoader'); module.exports = { id: /^ticket_.+$/, async execute(interaction, client) { const modalConfig = getModal(interaction.customId); - const staffRoles = (Array.isArray(config.staffRoles) ? config.staffRoles : [config.staffRoles]) - .filter(r => r && r.trim() !== ""); + const staffRoles = ( + Array.isArray(config.staffRoles) ? config.staffRoles : [config.staffRoles] + ).filter((r) => r && r.trim() !== ''); if (!modalConfig || modalConfig.Enabled === false) { const guild = interaction.guild; const member = interaction.member; const categories = config.TicketPanel.Panel.Categories; - const parentCategory = categories && categories.length > 0 ? categories[0] : null; + const parentCategory = + categories && categories.length > 0 ? categories[0] : null; const overwrites = [ { id: guild.id, deny: [PermissionFlagsBits.ViewChannel] }, @@ -32,9 +34,9 @@ module.exports = { allow: [ PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, - PermissionFlagsBits.ReadMessageHistory - ] - } + PermissionFlagsBits.ReadMessageHistory, + ], + }, ]; for (const roleId of staffRoles) { @@ -43,8 +45,8 @@ module.exports = { allow: [ PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, - PermissionFlagsBits.ReadMessageHistory - ] + PermissionFlagsBits.ReadMessageHistory, + ], }); } @@ -52,25 +54,29 @@ module.exports = { name: `ticket-${member.user.username}`.toLowerCase(), type: 0, parent: parentCategory || undefined, - permissionOverwrites: overwrites + permissionOverwrites: overwrites, }); createTicket(member.id, channel.id); await interaction.reply({ content: `✅ Ton ticket a été créé : ${channel}`, - flags: 64 + flags: 64, }); - await channel.send(`🎟️ Bonjour ${member}, un membre du staff va bientôt te répondre.`); + await channel.send( + `🎟️ Bonjour ${member}, un membre du staff va bientôt te répondre.` + ); - const logChannel = await client.channels.fetch(config.logsChannel).catch(() => null); + const logChannel = await client.channels + .fetch(config.logsChannel) + .catch(() => null); if (logChannel) { const embed = new EmbedBuilder() - .setTitle("🎟️ Nouveau ticket (sans formulaire)") + .setTitle('🎟️ Nouveau ticket (sans formulaire)') .addFields( - { name: "Utilisateur", value: `${member.user.tag} (${member.id})` }, - { name: "Salon", value: `${channel}` } + { name: 'Utilisateur', value: `${member.user.tag} (${member.id})` }, + { name: 'Salon', value: `${channel}` } ) .setColor(0x2ecc71) .setTimestamp(); @@ -83,9 +89,9 @@ module.exports = { const modal = new ModalBuilder() .setCustomId(`ticket_modal_${interaction.customId}`) - .setTitle(modalConfig.Title || "Création de ticket"); + .setTitle(modalConfig.Title || 'Création de ticket'); - modalConfig.Inputs.forEach(input => { + modalConfig.Inputs.forEach((input) => { const textInput = new TextInputBuilder() .setCustomId(input.CustomId) .setLabel(input.Label) @@ -96,5 +102,5 @@ module.exports = { }); await interaction.showModal(modal); - } -}; \ No newline at end of file + }, +}; diff --git a/interactions/ticketMenu.js b/interactions/ticketMenu.js index f93c3a2..8abed26 100644 --- a/interactions/ticketMenu.js +++ b/interactions/ticketMenu.js @@ -1,10 +1,17 @@ -const { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, PermissionFlagsBits, EmbedBuilder } = require("discord.js"); -const { getModal } = require("../handlers/modalHandler"); -const { createTicket } = require("../handlers/database"); -const { config } = require("../handlers/configLoader"); +const { + ModalBuilder, + TextInputBuilder, + TextInputStyle, + ActionRowBuilder, + PermissionFlagsBits, + EmbedBuilder, +} = require('discord.js'); +const { getModal } = require('../handlers/modalHandler'); +const { createTicket } = require('../handlers/database'); +const { config } = require('../handlers/configLoader'); module.exports = { - id: "ticket_select", + id: 'ticket_select', async execute(interaction, client) { const selected = interaction.values[0]; const modalConfig = getModal(selected); @@ -14,7 +21,8 @@ module.exports = { const member = interaction.member; const categories = config.TicketPanel.Panel.Categories; - const parentCategory = categories && categories.length > 0 ? categories[0] : null; + const parentCategory = + categories && categories.length > 0 ? categories[0] : null; const channel = await guild.channels.create({ name: `ticket-${member.user.username}`.toLowerCase(), @@ -27,37 +35,41 @@ module.exports = { allow: [ PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, - PermissionFlagsBits.ReadMessageHistory - ] + PermissionFlagsBits.ReadMessageHistory, + ], }, - ...config.staffRoles.map(roleId => ({ + ...config.staffRoles.map((roleId) => ({ id: roleId, allow: [ PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, - PermissionFlagsBits.ReadMessageHistory - ] - })) - ] + PermissionFlagsBits.ReadMessageHistory, + ], + })), + ], }); createTicket(member.id, channel.id); await interaction.reply({ content: `✅ Ton ticket a été créé : ${channel}`, - flags: 64 + flags: 64, }); - await channel.send(`🎟️ Bonjour ${member}, un membre du staff va bientôt te répondre.`); + await channel.send( + `🎟️ Bonjour ${member}, un membre du staff va bientôt te répondre.` + ); - const logChannel = await client.channels.fetch(config.logsChannel).catch(() => null); + const logChannel = await client.channels + .fetch(config.logsChannel) + .catch(() => null); if (logChannel) { const embed = new EmbedBuilder() - .setTitle("🎟️ Nouveau ticket (sans formulaire - via SelectMenu)") + .setTitle('🎟️ Nouveau ticket (sans formulaire - via SelectMenu)') .addFields( - { name: "Utilisateur", value: `${member.user.tag} (${member.id})` }, - { name: "Salon", value: `${channel}` }, - { name: "Type de ticket", value: selected } + { name: 'Utilisateur', value: `${member.user.tag} (${member.id})` }, + { name: 'Salon', value: `${channel}` }, + { name: 'Type de ticket', value: selected } ) .setColor(0x2ecc71) .setTimestamp(); @@ -70,9 +82,9 @@ module.exports = { const modal = new ModalBuilder() .setCustomId(`ticket_modal_${selected}`) - .setTitle(modalConfig.Title || "Création de ticket"); + .setTitle(modalConfig.Title || 'Création de ticket'); - modalConfig.Inputs.forEach(input => { + modalConfig.Inputs.forEach((input) => { const textInput = new TextInputBuilder() .setCustomId(input.CustomId) .setLabel(input.Label) @@ -83,5 +95,5 @@ module.exports = { }); await interaction.showModal(modal); - } -}; \ No newline at end of file + }, +}; diff --git a/interactions/ticketModal.js b/interactions/ticketModal.js index 3cc953f..57c53bb 100644 --- a/interactions/ticketModal.js +++ b/interactions/ticketModal.js @@ -1,17 +1,17 @@ -const { EmbedBuilder, PermissionFlagsBits } = require("discord.js"); -const { createTicket } = require("../handlers/database"); -const { config } = require("../handlers/configLoader"); +const { EmbedBuilder, PermissionFlagsBits } = require('discord.js'); +const { createTicket } = require('../handlers/database'); +const { config } = require('../handlers/configLoader'); module.exports = { id: /^ticket_modal_.+$/, async execute(interaction, client) { - const originalId = interaction.customId.replace("ticket_modal_", ""); + const originalId = interaction.customId.replace('ticket_modal_', ''); const modalConfig = config.TicketPanel?.Modals?.[originalId]; if (!modalConfig) { return interaction.reply({ - content: "❌ Aucun formulaire configuré pour ce ticket.", - flags: 64 + content: '❌ Aucun formulaire configuré pour ce ticket.', + flags: 64, }); } @@ -19,10 +19,12 @@ module.exports = { const guild = interaction.guild; const categories = config.TicketPanel.Panel.Categories; - const parentCategory = categories && categories.length > 0 ? categories[0] : null; + const parentCategory = + categories && categories.length > 0 ? categories[0] : null; - const staffRoles = (Array.isArray(config.staffRoles) ? config.staffRoles : [config.staffRoles]) - .filter(r => r && r.trim() !== ""); + const staffRoles = ( + Array.isArray(config.staffRoles) ? config.staffRoles : [config.staffRoles] + ).filter((r) => r && r.trim() !== ''); const overwrites = [ { id: guild.id, deny: [PermissionFlagsBits.ViewChannel] }, @@ -31,9 +33,9 @@ module.exports = { allow: [ PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, - PermissionFlagsBits.ReadMessageHistory - ] - } + PermissionFlagsBits.ReadMessageHistory, + ], + }, ]; for (const roleId of staffRoles) { @@ -42,8 +44,8 @@ module.exports = { allow: [ PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, - PermissionFlagsBits.ReadMessageHistory - ] + PermissionFlagsBits.ReadMessageHistory, + ], }); } @@ -51,46 +53,48 @@ module.exports = { name: `ticket-${member.user.username}`.toLowerCase(), type: 0, parent: parentCategory || undefined, - permissionOverwrites: overwrites + permissionOverwrites: overwrites, }); createTicket(member.id, channel.id); - const fieldsOutput = modalConfig.Inputs.map(input => { + const fieldsOutput = modalConfig.Inputs.map((input) => { const value = interaction.fields.getTextInputValue(input.CustomId); return `**${input.Label}** : ${value}`; - }).join("\n"); + }).join('\n'); const embed = new EmbedBuilder() - .setTitle(`🎟️ ${modalConfig.Title || "Nouveau ticket"}`) + .setTitle(`🎟️ ${modalConfig.Title || 'Nouveau ticket'}`) .setDescription(`👤 Ouvert par: ${member}\n\n${fieldsOutput}`) .setColor(0x5e99ff) .setTimestamp(); await channel.send({ - content: staffRoles.map(r => `<@&${r}>`).join(" "), - embeds: [embed] + content: staffRoles.map((r) => `<@&${r}>`).join(' '), + embeds: [embed], }); await interaction.reply({ content: `✅ Ton ticket a été créé : ${channel}`, - flags: 64 + flags: 64, }); - const logChannel = await client.channels.fetch(config.logsChannel).catch(() => null); + const logChannel = await client.channels + .fetch(config.logsChannel) + .catch(() => null); if (logChannel) { const logEmbed = new EmbedBuilder() - .setTitle("🎟️ Nouveau ticket") + .setTitle('🎟️ Nouveau ticket') .setDescription(`Formulaire utilisé: \`${originalId}\``) .addFields( - { name: "Utilisateur", value: `${member.user.tag} (${member.id})` }, - { name: "Salon", value: `${channel}` }, - { name: "Réponses", value: fieldsOutput } + { name: 'Utilisateur', value: `${member.user.tag} (${member.id})` }, + { name: 'Salon', value: `${channel}` }, + { name: 'Réponses', value: fieldsOutput } ) .setColor(0x2ecc71) .setTimestamp(); await logChannel.send({ embeds: [logEmbed] }); } - } -}; \ No newline at end of file + }, +}; diff --git a/package.json b/package.json index c2a93e3..cbbb30e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,10 @@ "main": "index.js", "scripts": { "start": "node index.js", - "dev": "nodemon index.js" + "dev": "nodemon index.js", + "lint": "eslint .", + "lint:fix": "eslint . --fix", + "format": "prettier --write ." }, "keywords": [], "author": "UltraLion - https://ultralion.xyz", @@ -20,6 +23,12 @@ "yaml": "^2.8.1" }, "devDependencies": { - "nodemon": "^3.1.10" + "@eslint/js": "^9.34.0", + "eslint": "^9.34.0", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-prettier": "^5.5.4", + "globals": "^16.3.0", + "nodemon": "^3.1.10", + "prettier": "^3.6.2" } } \ No newline at end of file