chore: 🎉 initial commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
function loadEvents(client) {
|
||||
const eventsPath = path.join(__dirname, "../events");
|
||||
|
||||
function walk(dir) {
|
||||
const files = fs.readdirSync(dir, { withFileTypes: true });
|
||||
|
||||
for (const file of files) {
|
||||
const filePath = path.join(dir, file.name);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
walk(filePath);
|
||||
} else if (file.name.endsWith(".js")) {
|
||||
const event = require(filePath);
|
||||
|
||||
if (event.once) {
|
||||
client.once(event.name, (...args) => event.execute(...args, client));
|
||||
} else {
|
||||
client.on(event.name, (...args) => event.execute(...args, client));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
walk(eventsPath);
|
||||
}
|
||||
|
||||
module.exports = { loadEvents };
|
||||
Reference in New Issue
Block a user