mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-09-20 11:05:58 +03:00
33 lines
870 B
JavaScript
33 lines
870 B
JavaScript
|
// 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));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
};
|