feat: mise à jour du code
This commit is contained in:
+29
-24
@@ -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 !`);
|
||||
}
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user