-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathserver.mjs
42 lines (35 loc) · 1.06 KB
/
server.mjs
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
// External dependencies
import { Client, GatewayIntentBits, Partials } from 'discord.js'
// Internal dependencies
import parseConfig from './src/restructureConfig.mjs'
import trackReactions from './src/trackReactions.mjs'
// Configuration
import CONFIG from './config.mjs'
import TOKEN from './token.mjs'
import checkMessages from './src/checkMessages.mjs'
const bot = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
Partials.GuildMember,
Partials.User]
})
const messageScheme = parseConfig(CONFIG)
// Start tracking messages by adding event listeners
trackReactions(bot, messageScheme)
bot.login(TOKEN)
.then(() => {
console.log(`Logged in as ${bot.user.tag}`)
// Check all messages for if the bot has still reacted to them
checkMessages(bot, messageScheme)
})
.catch(error => {
console.error('There was an error while trying to log in')
console.error(error)
})