forked from JDIS/JDIS-Discord-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
60 lines (52 loc) · 1.74 KB
/
bot.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/***
* Author: Timothy Landry
* Contributor:
* Description: First file execute when bot is launch. It's the file that log the bot in server
* and map command created by contributors.
*/
const fs = require("fs");
const Discord = require("discord.js");
const Enmap = require("enmap");
const config = require("./config.json");
const client = new Discord.Client({
intents: [Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.DIRECT_MESSAGES,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_INVITES]
});
client.config = config;
client.commands = new Enmap();
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files
.filter(file => file.endsWith(".js"))
.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
});
});
client.restCommands = [];
const folders = [
"./commands/examples/",
"./commands/contributors/",
config.debug ? "./commands/debug/" : ""
]
folders.forEach(folder => {
fs.readdir(folder, (err, files) => {
if (err) return console.error(err);
files
.filter(file => file.endsWith(".js"))
.forEach(file => {
let command = require(`${folder}/${file}`);
client.restCommands.push(command.data.toJSON());
console.log(`Loading command: ${command.data.name}`);
client.commands.set(command.data.name, command);
});
});
});
client.on('error', console.error);
client.login(config.token);