mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
21 lines
807 B
JavaScript
21 lines
807 B
JavaScript
const logger = require('../services/logger');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { Collection } = require('discord.js');
|
|
|
|
exports.registerClientCommands = (client) => {
|
|
logger.debug('Registering client commands...');
|
|
|
|
client.commands = new Collection();
|
|
const commandFolders = fs.readdirSync(path.resolve('./src/commands'));
|
|
for (const folder of commandFolders) {
|
|
const commandFiles = fs.readdirSync(path.resolve(`./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);
|
|
}
|
|
}
|
|
};
|