mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 06:28:53 +00:00
feat!: Extracted logic from index.js to separate files
This commit is contained in:
1 parent
dd4b56ae67
commit
2818778663
5 files changed
+111
-75
No files matched your search
@@ -0,0 +1,19 @@
|
||||
const logger = require('../services/logger');
|
||||
const fs = require('node:fs');
|
||||
const { Collection } = require('discord.js');
|
||||
|
||||
exports.registerClientCommands = (client) => {
|
||||
logger.debug('Registering client commands...');
|
||||
|
||||
client.commands = new Collection();
|
||||
const commandFolders = fs.readdirSync('./src/commands');
|
||||
for (const folder of commandFolders) {
|
||||
const commandFiles = fs.readdirSync(`./src/commands/${folder}`).filter((file) => file.endsWith('.js'));
|
||||
|
||||
for (const file of commandFiles) {
|
||||
logger.debug(`Registering command ${folder}/${file}...`);
|
||||
const command = require(`../commands/${folder}/${file}`);
|
||||
client.commands.set(command.data.name, command);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user