2020-10-22 05:48:50 +02:00
|
|
|
require("dotenv").config();
|
2018-07-14 01:01:37 +02:00
|
|
|
require('./util');
|
2018-07-14 05:29:41 +02:00
|
|
|
global.config = require('./config');
|
|
|
|
if (config.testmode) console.log('TEST MODE');
|
2018-05-12 07:19:31 +02:00
|
|
|
global.exitHook = require('async-exit-hook');
|
|
|
|
global.Discord = require('discord.js');
|
|
|
|
global.fs = require('fs');
|
2022-01-04 05:40:43 +01:00
|
|
|
global.dClient = new Discord.Client({
|
|
|
|
intents: 32767,
|
2022-01-04 06:31:34 +01:00
|
|
|
restRequestTimeout: 5*60*1000,
|
|
|
|
allowedMentions: {parse: []}
|
2022-01-04 05:40:43 +01:00
|
|
|
});
|
2018-05-12 07:19:31 +02:00
|
|
|
|
2018-08-14 08:10:31 +02:00
|
|
|
// error handling
|
|
|
|
{
|
2022-01-05 01:01:27 +01:00
|
|
|
let webhook = new Discord.WebhookClient({url: config.webhooks.error}, {allowedMentions: {parse: []}});
|
2022-01-04 05:40:43 +01:00
|
|
|
global.handleError = function logError(error, title) {
|
2018-08-31 00:45:23 +02:00
|
|
|
let msg = error && (error.stack || error.message || error);
|
2022-01-04 05:40:43 +01:00
|
|
|
console.error(title + ':\n' + msg);
|
2018-08-14 08:10:31 +02:00
|
|
|
try {
|
2018-09-12 04:41:16 +02:00
|
|
|
webhook.send(`${title ? `**${title}:**` : ""}\`\`\`\n${msg}\n\`\`\``).catch(()=>{});
|
2018-08-14 08:10:31 +02:00
|
|
|
} catch(e) {}
|
|
|
|
}
|
2022-01-04 05:40:43 +01:00
|
|
|
process.on('unhandledRejection', error => handleError(error, "Unhandled Rejection"));
|
|
|
|
exitHook.uncaughtExceptionHandler(error => handleError(error, "Uncaught Exception"));
|
|
|
|
dClient.on('error', error => handleError(error, "Discord Client Error"));
|
|
|
|
dClient.on('warn', error => handleError(error, "Discord Client Warning"));
|
2018-09-19 08:47:50 +02:00
|
|
|
|
2018-08-14 08:10:31 +02:00
|
|
|
}
|
|
|
|
|
2022-01-04 04:04:16 +01:00
|
|
|
dClient.login(config.DISCORD_TOKEN);
|
2018-05-12 07:19:31 +02:00
|
|
|
|
2022-01-04 07:45:28 +01:00
|
|
|
dClient.on('ready', () => {
|
2018-05-12 07:19:31 +02:00
|
|
|
console.log('Discord Client Ready');
|
2018-08-31 00:45:23 +02:00
|
|
|
});
|
2022-01-04 07:45:28 +01:00
|
|
|
|
|
|
|
require('./eval-exec');
|
|
|
|
require("./commands");
|
|
|
|
require('./mppbridger');
|
|
|
|
require('./misc');
|
|
|
|
require('./ddpbridge');
|