Browse Source
fix: use __dirname instead of working directory so index can be run from anywhere
development
Abheek Dhawan
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
4 additions and
4 deletions
-
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)); |
|
|
|