-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
27 lines (21 loc) · 961 Bytes
/
Copy pathmain.js
File metadata and controls
27 lines (21 loc) · 961 Bytes
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
require('module-alias/register')
const Discord = require("discord.js")
const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] })
const config = require('./config.json');
const error = require("@util/error.js");
const readLastLines = require('read-last-lines');
const log = require("@util/log.js")
var logBackup = console.log;
console.log = function () {
logBackup.apply(console, arguments);
readLastLines.read('./log.txt', 1)
.then((lines) => log.send(lines));
}
client.commands = new Discord.Collection();
client.events = new Discord.Collection();
['command_handler', 'event_handler'].forEach(handler => {
require(`./handlers/${handler}`)(client, Discord)
})
process.on("unhandledRejection", (e) => error.send("UnhandledRejection: " + e.stack ?? e, { files: ["./log.txt"] }))
process.on("uncaughtException", (e, o) => error.send("UnhandledRejection: " + (e.stack ?? e) + "\n" + o))
client.login(config.token)