mirror of
https://github.com/arthur-pbty/selfbot-discord.git
synced 2026-06-14 08:08:26 +02:00
init sb
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { Client } from 'discord.js';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
module.exports = function loadEvents(client: Client, dir: string): number {
|
||||
let count = 0;
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach((file: string) => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
loadEvents(client, path.join(dir, file));
|
||||
} else if (file.endsWith('.js') || file.endsWith('.ts')) {
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const event = require(filePath);
|
||||
if (typeof event.execute === 'function') {
|
||||
client.on(event.name, (...args: any[]) => event.execute(...args, client)); // Specify the type of 'args' as an array of any type
|
||||
count++;
|
||||
} else {
|
||||
console.error(`Event ${event.name} does not have an execute method.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
Reference in New Issue
Block a user