Program Commit
This commit is contained in:
15
discord-bot/handlers/command-handler.js
Normal file
15
discord-bot/handlers/command-handler.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (client) => {
|
||||
const commandsPath = path.join(__dirname, '../commands');
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
const command = require(filePath);
|
||||
if (command.name) {
|
||||
client.commands.set(command.name, command);
|
||||
}
|
||||
}
|
||||
};
|
||||
17
discord-bot/handlers/event-handler.js
Normal file
17
discord-bot/handlers/event-handler.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (client) => {
|
||||
const eventsPath = path.join(__dirname, '../events');
|
||||
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of eventFiles) {
|
||||
const filePath = path.join(eventsPath, file);
|
||||
const event = require(filePath);
|
||||
if (event.once) {
|
||||
client.once(event.name, (...args) => event.execute(...args, client));
|
||||
} else {
|
||||
client.on(event.name, (...args) => event.execute(...args, client));
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user