init
Some checks failed
Gitea Auto Deploy / Deploy-Container (push) Failing after 6s

This commit is contained in:
2025-05-25 22:29:44 +07:00
commit 5eb5aa6eec
27 changed files with 1998 additions and 0 deletions

26
src/events/index.ts Normal file
View File

@@ -0,0 +1,26 @@
import { Client } from "discord.js";
import path from "path";
import fs from "fs";
export default function ActiveAllEvents(client: Client) {
const eventFolder = path.join(__dirname);
for (const folder of fs.readdirSync(eventFolder)) {
const folderPath = path.join(eventFolder, folder);
if (!fs.statSync(folderPath).isDirectory()) continue;
const eventFiles = fs.readdirSync(folderPath).filter(file => file.endsWith(".ts"));
for (const file of eventFiles) {
const event = require(path.join(folderPath, file));
if (!event.name || typeof event.execute !== "function") {
console.log(`Event at ${path.join(folderPath, file)} is missing a name or execute function`);
continue;
}
// console.log(`Event ${event.name} loaded`);
if (event.once) {
client.once(event.name, (...args) => event.execute(client, ...args));
} else {
client.on(event.name, (...args) => event.execute(client, ...args));
}
}
}
}