-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 1.04 KB
/
index.js
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
30
31
32
33
34
const Discord = require('discord.js');
const client = new Discord.Client({disableEveryone: true});
const Canvas = require("canvas");
const fs = require("fs");
const config = require(`./config.json`);
const prefix = config.prefix;
client.commands = new Discord.Collection();
client.afk = new Map();
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, (...args) => eventFunc.run(client, ...args));
});
});
fs.readdir(`./commands`, (err, directories) => {
if (err) return console.error(error);
directories.forEach(directory => {
fs.readdir(`./commands/${directory}`, (e, files) => {
if (e) return console.error(e);
files.forEach(file => {
const eventFunc = require(`./commands/${directory}/${file}`);
let eventName = file.split(".")[0];
client.commands.set(eventName, eventFunc);
});
});
});
});
client.login(process.env.BOT_TOKEN);