feat: mise à jour du code

This commit is contained in:
UltraLionFr
2025-08-26 01:21:58 +02:00
parent 944845cd11
commit d3d3642ec3
29 changed files with 487 additions and 320 deletions
+1 -2
View File
@@ -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 };
module.exports = { scheduleTicketClosure, cancelTicketClosure };
+8 -6
View File
@@ -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 };
module.exports = { loadButtons, handleButton };
+7 -7
View File
@@ -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 };
module.exports = { loadCommands, getCommandsJSON };
+8 -8
View File
@@ -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 };
module.exports = { config, lang };
+5 -5
View File
@@ -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 };
module.exports = { initDB, createTicket, getTicketByChannel, closeTicket };
+5 -5
View File
@@ -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 };
module.exports = { loadEvents };
+10 -10
View File
@@ -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;
module.exports = logger;
+9 -7
View File
@@ -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 };
module.exports = { loadMenus, handleMenu };
+9 -7
View File
@@ -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 };
module.exports = { loadModals, getModal };