From df35b41e7f6e645927f13acb7fe5087d5f77549f Mon Sep 17 00:00:00 2001 From: Abheek Dhawan <67982792+ADawesomeguy@users.noreply.github.com> Date: Wed, 13 Jul 2022 12:18:28 -0500 Subject: [PATCH] fix: use __dirname instead of working directory so index can be run from anywhere --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 575fa2c..1567f02 100755 --- a/src/index.ts +++ b/src/index.ts @@ -11,11 +11,11 @@ const client = new Client({ client['commands'] = new Collection(); -const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); -const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js')); +const commandFiles = fs.readdirSync(`${__dirname}/commands`).filter(file => file.endsWith('.js')); +const eventFiles = fs.readdirSync(`${__dirname}/events`).filter(file => file.endsWith('.js')); for (const file of commandFiles) { - import(`./commands/${file}`) + import(`${__dirname}/commands/${file}`) .then(command => { client['commands'].set(command.data.name, command); log({ logger: 'command', content: `Registered command ${file}!`, level: 'info' }); @@ -23,7 +23,7 @@ for (const file of commandFiles) { } for (const file of eventFiles) { - import(`./events/${file}`) + import(`${__dirname}/events/${file}`) .then(event => { if (event.once) { client.once(event.name, (...args) => event.execute(...args));