forked from TheOdinProject/odin-bot-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (23 loc) · 1.2 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
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const glob = require('glob');
const path = require('path');
const { listenToMessages, listenToReactions, listenToInteractions } = require('./botEngine.js');
const { guildId, token } = require('./config.js');
require('./bin/deploy-commands.js');
glob.sync('./botCommands/**/*.js', { ignore: './botCommands/**/*.test.js' }).forEach((file) => {
require(`${path.resolve(file)}`); // eslint-disable-line global-require, import/no-dynamic-require
});
const client = new Client({
intents: [GatewayIntentBits.MessageContent, GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.DirectMessageReactions], // eslint-disable-line max-len
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});
client.once('ready', async () => {
console.log('Bot session started:', new Date());
// Fetch Guild members on startup to ensure the integrity of the cache
const guild = await client.guilds.fetch(guildId);
await guild.members.fetch();
});
listenToMessages(client);
listenToReactions(client);
listenToInteractions(client);
client.login(token);