-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
19 lines (17 loc) · 813 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const Discord = require('discord.js');
const client = new Discord.Client();
const botconfig = require(`./bot_config`);
const fs = require('fs');
fs.readdir('./events/', (err, files) =>
{
files.forEach(file =>
{
const eventHandler = require(`./events/${file}`) //eventHandler refrences the other files/scripts/class (like GamManager in GM.deltaTime)
const eventName = file.split('.')[0] //file name without extension
client.on(eventName, function (...arg) { eventHandler(client, ...arg) })
//client.on(name, arguments) creates the event with eventName
//eventName becomes an event which calls eventHandler function with the input (client,args)
//where client is clienet and ...args is any amount of input by user
})
})
client.login(botconfig.token);