This repository was archived by the owner on Oct 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbot.js
More file actions
66 lines (52 loc) · 1.88 KB
/
bot.js
File metadata and controls
66 lines (52 loc) · 1.88 KB
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
require('dotenv').config()
const http = require('http')
const express = require('express')
const app = express()
app.get("/", (request, response) => {
response.sendStatus(200)
})
app.listen(process.env.PORT);
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`)
}, 280000)
const Discord = require('discord.js')
const fs = require('fs')
const config = require('./config.js')
const client = new Discord.Client({
disabledEvents: ['TYPING_START'],
restWsBridgeTimeout: 10000,
restTimeOffset: 1000
})
client.config = config
client.dversion = Discord.version
client.utils = require('./includes/utilities')
client.db = require('./includes/database')
client.pl = require('./includes/powerlevels')
// Taken from an idiot's guide
// Loading events
const eventFiles = fs.readdirSync('./events/').filter(file => file.endsWith('.js'))
eventFiles.forEach(file => {
const filename = `./events/${file}`
const eventName = file.split('.')[0]
const event = require(filename)
client.on(eventName, event.bind(null, client))
})
// Loading commands
client.commands = new Discord.Collection()
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'))
commandFiles.forEach(file => {
const filename = `./commands/${file}`
const command = require(filename)
const commandName = file.split('.')[0]
client.commands.set(commandName, command)
})
client.login(process.env.BOT_TOKEN)
process.on('unhandledRejection', (error, p) => {
console.error(error)
client.specialChannels.ERROR_LOG.send(new Discord.RichEmbed().setColor(0xFFFF00).setTitle(`Unhandled promise rejection as ${p}`).setDescription(error.toString()))
})
process.on('uncaughtException', error => {
console.error(error.stack)
client.specialChannels.ERROR_LOG.send(new Discord.RichEmbed().setColor(0xFF0000).setTitle(`Uncaught exception`).setDescription(error.stack))
process.exit(1)
})