loader add

This commit is contained in:
VALOU3336
2024-02-13 21:45:11 +01:00
parent a0a674fcad
commit 804de4d5f0
6 changed files with 80 additions and 8 deletions
+14
View File
@@ -0,0 +1,14 @@
const { Events, InteractionType } = require("discord.js")
module.exports = {
name :Events.InteractionCreate,
async run(client, interaction) {
if(interaction.type === InteractionType.ApplicationCommand) {
const command = client.commands.get(interaction.commandName);
await command.execute(interaction, client);
};
}
};
+11
View File
@@ -0,0 +1,11 @@
const { Events, ActivityType } = require("discord.js")
module.exports = {
name : Events.ClientReady,
async run(client) {
client.application.commands.set(client.commands.map(command => command.data));
console.log(`${client.user.username} est en ligne`);
},
};
+19
View File
@@ -0,0 +1,19 @@
const { readdirSync } = require("fs");
module.exports = async client => {
let count = 0;
const dirsCommands = readdirSync("./commands/");
for(const dirs of dirsCommands) {
const filesDirs = readdirSync(`./commands/${dirs}/`).filter(f => f.endsWith(".js"));
for(const files of filesDirs) {
const command = require(`../commands/${dirs}/${files}`);
client.commands.set(command.data.name, command);
count++;
}
};
console.log(`[Commands Slash] => ${count} logged commands`);
}
+22
View File
@@ -0,0 +1,22 @@
const { readdirSync } = require("fs");
module.exports = async client => {
let count = 0;
const dirsEvents = readdirSync("./events/");
for(const dirs of dirsEvents) {
const filesDirs = readdirSync(`./events/${dirs}/`).filter(f => f.endsWith(".js"));
for(const files of filesDirs) {
const event = require(`../events/${dirs}/${files}`);
if(dirs === "music") client.player.events.on(event.name, (...args) => event.run(client, ...args));
else client.on(event.name, (...args) => event.run(client, ...args));
count++;
};
};
console.log(`Event => ${count} chargé sur le bot`)
};
+14
View File
@@ -0,0 +1,14 @@
const fs = require('fs');
const path = require('path');
module.exports = async (client) => {
const prefixCommandsPath = path.join(__dirname, '../commandprefix'); // Ajustez le chemin ici
const commandFiles = fs.readdirSync(prefixCommandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`../commandprefix/${file}`); // Ajustez le chemin ici
client.prefixCommands.set(command.name, command);
}
console.log(`[Prefix Commands] => ${client.prefixCommands.size} prefix commands loaded`);
};
-8
View File
@@ -7,12 +7,4 @@ client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
client.login(process.env.TOKEN);