-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadCommands.ts
More file actions
29 lines (21 loc) · 864 Bytes
/
Copy pathloadCommands.ts
File metadata and controls
29 lines (21 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {readdir} from 'fs';
import { Bot } from '../models';
function loadCommands(bot:Bot) {
readdir('commands/', async (err, files) => {
if (err) console.log(err);
const jsfile = files.filter(f => f.endsWith('ts'));
if (jsfile.length <= 0) {
return console.log('Bot Couldn\'t Find Commands in commands Folder.');
}
jsfile.forEach(async (f, i) => {
const command = (await import(`../commands/${f}`)).default;
bot.commands.set(command.name, command);
command.config.aliases.forEach(alias => {
bot.aliases.set(alias, command.name);
});
console.log(`${i + 1}.) ${command.name} command is loaded!`);
if (i == jsfile.length - 1) console.log('Commands are loaded!');
});
});
}
export default loadCommands;