-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.js
77 lines (71 loc) · 1.92 KB
/
app.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const Discord = require('discord.js-light'),
parser = require('discord-command-parser'),
{ commands, analytics } = require('./commands')
const client = new Discord.Client({
presence: {
status: "online",
activity: {
type: 'WATCHING',
name: 'COVID19 data',
url: 'https://disease.sh'
}
},
restTimeOffset: 100,
partials: ["MESSAGE", "CHANNEL", "REACTION"],
ws: {
Intents: ["MESSAGE_CREATE", "MESSAGE_UPDATE"],
},
disabledEvents: [
"GUILD_MEMBER_ADD",
"GUILD_MEMBER_REMOVE",
"GUILD_MEMBER_UPDATE",
"GUILD_MEMBERS_CHUNK",
"GUILD_INTEGRATIONS_UPDATE",
"GUILD_ROLE_CREATE",
"GUILD_ROLE_DELETE",
"GUILD_ROLE_UPDATE",
"GUILD_BAN_ADD",
"GUILD_BAN_REMOVE",
"GUILD_EMOJIS_UPDATE",
"GUILD_MESSAGE_REACTIONS",
"CHANNEL_PINS_UPDATE",
"CHANNEL_CREATE",
"CHANNEL_DELETE",
"CHANNEL_UPDATE",
"MESSAGE_DELETE",
"MESSAGE_DELETE_BULK",
"MESSAGE_REACTION_REMOVE",
"MESSAGE_REACTION_REMOVE_ALL",
"MESSAGE_REACTION_REMOVE_EMOJI",
"USER_UPDATE",
"USER_SETTINGS_UPDATE",
"PRESENCE_UPDATE",
"TYPING_START",
"VOICE_STATE_UPDATE",
"VOICE_SERVER_UPDATE",
"INVITE_CREATE",
"INVITE_DELETE",
"WEBHOOKS_UPDATE",
]
}),
config = require('dotenv').config()
if (config.error) {
console.warn('[ERROR]: cannot parse .env file')
process.exit(-1)
}
const prefix = process.env.PREFIX || 'cov'
client.once('ready', () => console.log('[INFO]: bot is running'))
client.on('message', message => {
if (message.author.bot) return;
message.content = message.content.toLowerCase()
const parsed = parser.parse(message, prefix, { allowSpaceBeforeCommand: true })
try {
if (parsed.success && commands[parsed.command]) {
commands[parsed.command](message, parsed.arguments)
analytics[parsed.command] ? analytics[parsed.command]++ : (analytics[parsed.command] = 1)
}
}catch(err){
console.error(`'${err.message}' on channel ${message.channel.id} in guild ${message.guild.id}`)
}
})
client.login(process.env.TOKEN)