-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
20 lines (17 loc) · 734 Bytes
/
bot.js
File metadata and controls
20 lines (17 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const fs = require('fs');
const Discord = require('discord.js');
module.exports =
{
loadHandlers(client, subdir)
{
// Gather a list of all of our individual handler functions
const files = fs.readdirSync(`${client.botConfig.rootDir}/handlers/${subdir}`).filter(file => file.endsWith('.js'));
// Creates an empty list in the client object to store all functions
client[subdir] = new Discord.Collection();
// Loops over each file in the folder and sets the functions to respond to themselves
for (const file of files) {
const func = require(`${client.botConfig.rootDir}/handlers/${subdir}/${file}`);
client[subdir].set(func.name, func);
}
}
}