-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (51 loc) · 1.64 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* suggestion-bot
* A bot that suggests things to do
* @author: @FoobarIT
* @license: MIT
* @version: 1.0.0
* @repository: to define
**/
require('dotenv').config();
const Discord = require('discord.js');
const {GatewayIntentBits, Collection} = require('discord.js');
const { token} = require('./bot-config')
const fs = require('fs');
const path = require('path');
// Create an instance of a Discord client and define Intents
const client = new Discord.Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMembers,
]
});
// New command collection
client.commands = new Collection();
const init = async () => {
// Then we load events, which will include our message and ready event.
client.events = {}
fs.readdir('./events', (err, files) => {
try {
files.forEach(file => {
var eventName = file.split('.')[0]
var prop = require(`./events/${file}`)
client.events[eventName] = prop
client.on(eventName, prop.bind(null, client))
})
} catch (err) {
console.log(err)
}
})
// Load all commands files from the commands folder
const commands = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for (const file of commands) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
// Login to Discord with your client's token
client.login(token);
}
init();