#why doesn't work?
1 messages · Page 1 of 1 (latest)
handler event
export default async function init(client: Client) {
client.logger.send(`[HANDLER/EVENTS] Hanfler event loaded.`);
await walk(client, './dist/events/');
}
async function walk(client: Client, dir: string) {
if (Array.isArray(dir)) return;
if (!(await lstat(dir)).isDirectory() ) {
const event: BaseEvent = (await import(`../${dir}`.replace('/dist', '')))?.default;
if (event.once) {
client.once(event.name, (...args) => event.execute(client, ...args));
} else {
client.on(event.name, (...args) => event.execute(client, ...args));
}
client.logger.send(`[HANDLER/EVENTS] Listener "${event.name}" loaded.`);
return;
}
for(let file of (await readdir(dir))) {
await walk(client, join(dir, file));
}
return;
}
in what way does it not work?
do you have any errors?
no errors
ready event is loaded, but not working
I'll just assume by "not working" you mean that it doesn't execute at all
does this walk function get called at all?
where do you even log in?
other events work successfully
I login like this:
client.login(process.env.TOKEN)
.then(async() => {
await client.logger.init(client);
client.logger.send(`[INDEX] Bot initialization`);
(await import(`./handlers/events`)).default(client).catch(client.logger.error);
(await import(`./handlers/commands`)).default(client).catch(client.logger.error);
client.on('error', client.logger.error)
client.on('warn', client.logger.send)
process.on('uncaughtException', client.logger.error);
process.on('unhandledRejection', client.logger.error);
});
yes
then you should consider listening to events before logging in
the ready event is emitting before you listen to it
walk is in the event handler
ok