mirror of
https://github.com/Ninluc/Dat_Boi.git
synced 2025-08-09 23:26:13 +02:00
Initial commit
This commit is contained in:
40
handlers/events.js
Executable file
40
handlers/events.js
Executable file
@ -0,0 +1,40 @@
|
||||
const fs = require("fs");
|
||||
const ascii = require("ascii-table");
|
||||
let table = new ascii("Events");
|
||||
table.setHeading("Events", "Load status");
|
||||
const allevents = [];
|
||||
module.exports = async (client) => {
|
||||
try{
|
||||
const load_dir = (dir) => {
|
||||
const event_files = fs.readdirSync(`./events/${dir}`).filter((file) => file.endsWith(".js"));
|
||||
for (const file of event_files){
|
||||
const event = require(`../events/${dir}/${file}`)
|
||||
let eventName = file.split(".")[0];
|
||||
allevents.push(eventName);
|
||||
client.on(eventName, event.bind(null, client));
|
||||
}
|
||||
}
|
||||
await ["client", "guild"].forEach(e=>load_dir(e));
|
||||
for (let i = 0; i < allevents.length; i++) {
|
||||
try {
|
||||
table.addRow(allevents[i], "Ready");
|
||||
} catch (e) {
|
||||
console.log(String(e.stack).red);
|
||||
}
|
||||
}
|
||||
console.log(table.toString().cyan);
|
||||
try{
|
||||
const stringlength2 = 69;
|
||||
console.log("\n")
|
||||
console.log(` ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓`.bold.yellow)
|
||||
console.log(` ┃ `.bold.yellow + " ".repeat(-1+stringlength2-` ┃ `.length)+ "┃".bold.yellow)
|
||||
console.log(` ┃ `.bold.yellow + `Logging into the BOT...`.bold.yellow + " ".repeat(-1+stringlength2-` ┃ `.length-`Logging into the BOT...`.length)+ "┃".bold.yellow)
|
||||
console.log(` ┃ `.bold.yellow + " ".repeat(-1+stringlength2-` ┃ `.length)+ "┃".bold.yellow)
|
||||
console.log(` ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛`.bold.yellow)
|
||||
}catch{ /* */ }
|
||||
}catch (e){
|
||||
console.log(String(e.stack).bgRed)
|
||||
}
|
||||
};
|
||||
|
||||
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */
|
Reference in New Issue
Block a user