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
parent
commit
df35b41e7f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/index.ts

8
src/index.ts

@ -11,11 +11,11 @@ const client = new Client({
client['commands'] = new Collection(); client['commands'] = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); const commandFiles = fs.readdirSync(`${__dirname}/commands`).filter(file => file.endsWith('.js'));
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js')); const eventFiles = fs.readdirSync(`${__dirname}/events`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) { for (const file of commandFiles) {
import(`./commands/${file}`) import(`${__dirname}/commands/${file}`)
.then(command => { .then(command => {
client['commands'].set(command.data.name, command); client['commands'].set(command.data.name, command);
log({ logger: 'command', content: `Registered command ${file}!`, level: 'info' }); log({ logger: 'command', content: `Registered command ${file}!`, level: 'info' });
@ -23,7 +23,7 @@ for (const file of commandFiles) {
} }
for (const file of eventFiles) { for (const file of eventFiles) {
import(`./events/${file}`) import(`${__dirname}/events/${file}`)
.then(event => { .then(event => {
if (event.once) { if (event.once) {
client.once(event.name, (...args) => event.execute(...args)); client.once(event.name, (...args) => event.execute(...args));

Loading…
Cancel
Save