forked from Supositware/Haha-Yes
Compare commits
1 commit
fa95596906
...
634e4a85af
Author | SHA1 | Date | |
---|---|---|---|
634e4a85af |
1 changed files with 18 additions and 13 deletions
15
index.js
15
index.js
|
@ -37,11 +37,13 @@ async function loadCommandFromDir(dir) {
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
const filePath = path.join(commandsPath, file);
|
const filePath = path.join(commandsPath, file);
|
||||||
let command = await import(filePath);
|
import(filePath)
|
||||||
command = command.default;
|
.then(importedCommand => {
|
||||||
|
const command = importedCommand.default;
|
||||||
client.commands.set(command.data.name, command);
|
client.commands.set(command.data.name, command);
|
||||||
console.log(`Successfully loaded command \x1b[32m${command.category}/${command.data.name}\x1b[0m`);
|
console.log(`Successfully loaded command \x1b[32m${command.category}/${command.data.name}\x1b[0m`);
|
||||||
|
})
|
||||||
|
.catch(error => console.error(`Failed to load command for path: ${filePath}`, error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +53,16 @@ async function loadEventFromDir(dir, listener) {
|
||||||
|
|
||||||
for (const file of eventFiles) {
|
for (const file of eventFiles) {
|
||||||
const filePath = path.join(eventsPath, file);
|
const filePath = path.join(eventsPath, file);
|
||||||
let event = await import(filePath);
|
import(filePath)
|
||||||
event = event.default;
|
.then(importedEvent => {
|
||||||
|
const event = importedEvent.default;
|
||||||
if (event.once) {
|
if (event.once) {
|
||||||
listener.once(event.name, (...args) => event.execute(...args, client));
|
listener.once(event.name, (...args) => event.execute(...args, client));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
listener.on(event.name, (...args) => event.execute(...args, client));
|
listener.on(event.name, (...args) => event.execute(...args, client));
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(error => console.error(`Failed to load event for path: ${filePath}`, error));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue