mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-08 02:51:25 +03:00
Improvements and fixes, start on command manager
This commit is contained in:
33
src/modules/commands/manager.js
Normal file
33
src/modules/commands/manager.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { Collection, Client } = require('discord.js');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Command = require('./command');
|
||||
|
||||
const fs = require('fs');
|
||||
const { path } = require('../../utils/fs');
|
||||
|
||||
/** Manages the loading of commands */
|
||||
module.exports = class CommandManager {
|
||||
/**
|
||||
* Create a CommandManager instance
|
||||
* @param {Client} client
|
||||
*/
|
||||
constructor(client) {
|
||||
/** The Discord Client */
|
||||
this.client = client;
|
||||
/** A discord.js Collection (Map) of loaded commands */
|
||||
this.commands = new Collection();
|
||||
}
|
||||
|
||||
/** Automatically load all internal commands */
|
||||
load() {
|
||||
const files = fs.readdirSync(path('./src/commands'))
|
||||
.filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of files) {
|
||||
const cmd = require(`../commands/${file}`);
|
||||
this.commands.set(cmd, new cmd(this.client));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
Reference in New Issue
Block a user