Update 1.0.0

This commit is contained in:
Noah Pombas
2024-04-21 19:07:51 +02:00
parent a58330ec0a
commit 584afd0fe6
9 changed files with 296 additions and 3 deletions

64
handler/index.js Normal file
View File

@@ -0,0 +1,64 @@
const fs = require("node:fs");
const chalk = require("chalk");
//Carregar eventos
const loadEvents = async function (client) {
const eventFolders = fs.readdirSync("./events");
for (const folder of eventFolders) {
const eventFiles = fs
.readdirSync(`./events/${folder}`)
.filter((file) => file.endsWith(".js"));
for (const file of eventFiles) {
const event = require(`../events/${folder}/${file}`);
if (event.name) {
console.log(chalk.greenBright(` ✔️ => ${file} Event loaded.`));
} else {
console.log(chalk.redBright(` ❌ => ${file} Event not loaded.`));
continue;
}
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
}
}
//Carregar slashcommands
const loadSlashCommands = async function (client) {
let slash = []
const commandFolders = fs.readdirSync("./commands");
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./commands/${folder}`)
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`../commands/${folder}/${file}`);
if (command.name) {
client.slash.set(command.name, command);
slash.push(command)
console.log(chalk.greenBright(` ✔️ => ${file} Command loaded`));
} else {
console.log(chalk.redBright(` ❌ => ${file} Command not loaded`));
continue;
}
}
}
client.on("ready", async () => {
await client.guilds.cache.get("yourDiscordServerID").commands.set(slash);
})
}
module.exports = {
loadEvents,
loadSlashCommands
}