chore: 🎉 initial commit

This commit is contained in:
UltraLionFr
2025-08-26 01:01:34 +02:00
parent bf6d61e5a3
commit 30cfbd73fc
27 changed files with 1341 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
const { REST, Routes } = require("discord.js");
const { getCommandsJSON } = require("../../handlers/commandHandler");
const logger = require("../../handlers/logger");
module.exports = {
name: "clientReady",
once: true,
async execute(client) {
const commands = getCommandsJSON();
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.success(`${commands.length} slash commands déployées avec succès !`);
} catch (error) {
logger.error(`❌ Erreur lors du déploiement des commandes : ${error.message}`);
}
}
};
+99
View File
@@ -0,0 +1,99 @@
const {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
EmbedBuilder,
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);
const asInt = parseInt(raw);
if (!isNaN(asInt)) return asInt;
}
return 0x5865F2;
}
module.exports = {
name: "clientReady",
once: true,
async execute(client) {
const panelConfig = config.TicketPanel.Panel;
const channelId = Array.isArray(panelConfig.Channel)
? panelConfig.Channel[0]
: panelConfig.Channel;
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.");
}
// === Embed principal ===
const embed = new EmbedBuilder()
.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.Timestamp) embed.setTimestamp();
if (panelConfig.Embed.Footer && panelConfig.Embed.Footer.Enabled) {
embed.setFooter({
text: panelConfig.Embed.Footer.Text || "",
iconURL: panelConfig.Embed.Footer.CustomIconURL || null
});
}
let row;
// === Gestion des interactions ===
if (panelConfig.InteractionType === "select" && panelConfig.SelectMenu) {
// 📌 Mode Select Menu
const menu = new StringSelectMenuBuilder()
.setCustomId("ticket_select")
.setPlaceholder(panelConfig.SelectMenu.Placeholder || "Choisis une option...");
for (const opt of panelConfig.SelectMenu.Options) {
const option = {
label: opt.Label,
value: opt.Value,
};
if (opt.Description) option.description = opt.Description;
if (opt.Emoji) option.emoji = opt.Emoji;
menu.addOptions(option);
}
row = new ActionRowBuilder().addComponents(menu);
} else {
// 📌 Mode Boutons par défaut
row = new ActionRowBuilder();
if (panelConfig.Buttons && Array.isArray(panelConfig.Buttons)) {
for (const btn of panelConfig.Buttons) {
row.addComponents(
new ButtonBuilder()
.setCustomId(btn.CustomId)
.setLabel(btn.Label)
.setStyle(ButtonStyle[btn.Style])
);
}
}
}
// === Nettoyage & envoi ===
await channel.bulkDelete(10).catch(() => {});
await channel.send({ embeds: [embed], components: [row] });
logger.success(`✅ Panel "${panelConfig.Name}" envoyé avec succès !`);
}
};
+9
View File
@@ -0,0 +1,9 @@
const logger = require("../../handlers/logger");
module.exports = {
name: "clientReady",
once: true,
execute(client) {
logger.success(`Connecté en tant que ${client.user.tag}`);
}
};
+61
View File
@@ -0,0 +1,61 @@
module.exports = {
name: "interactionCreate",
once: false,
async execute(interaction, client) {
try {
// Slash commands
if (interaction.isChatInputCommand()) {
const command = client.commands.get(interaction.commandName);
if (command) return command.execute(interaction, client);
}
// Buttons
if (interaction.isButton()) {
for (const button of client.buttons.values()) {
if (typeof button.id === "string" && button.id === interaction.customId) {
return button.execute(interaction, client);
}
if (button.id instanceof RegExp && button.id.test(interaction.customId)) {
return button.execute(interaction, client);
}
}
}
// Modals
if (interaction.isModalSubmit()) {
for (const modal of client.modals.values()) {
if (typeof modal.id === "string" && modal.id === interaction.customId) {
return modal.execute(interaction, client);
}
if (modal.id instanceof RegExp && modal.id.test(interaction.customId)) {
return modal.execute(interaction, client);
}
}
}
// Menus
if (
interaction.isStringSelectMenu() ||
interaction.isUserSelectMenu() ||
interaction.isRoleSelectMenu() ||
interaction.isChannelSelectMenu()
) {
for (const menu of client.menus.values()) {
if (typeof menu.id === "string" && menu.id === interaction.customId) {
return menu.execute(interaction, client);
}
if (menu.id instanceof RegExp && menu.id.test(interaction.customId)) {
return menu.execute(interaction, client);
}
}
}
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: "❌ Une erreur est survenue.", flags: 64 });
} else {
await interaction.reply({ content: "❌ Une erreur est survenue.", flags: 64 });
}
}
}
};
+26
View File
@@ -0,0 +1,26 @@
const { getTicketByChannel } = require("../../handlers/database");
const { cancelTicketClosure } = require("../../handlers/alertManager");
const { lang } = require("../../handlers/configLoader");
const { EmbedBuilder } = require("discord.js");
module.exports = {
name: "messageCreate",
once: false,
async execute(message) {
if (message.author.bot) return;
const ticket = getTicketByChannel(message.channel.id);
if (!ticket) return;
if (message.author.id === ticket.userId) {
if (cancelTicketClosure(message.channel.id)) {
const embed = new EmbedBuilder()
.setDescription(lang.commands.alert.auto_cancelled)
.setColor(0x2ecc71)
.setTimestamp();
await message.channel.send({ embeds: [embed] });
}
}
}
};