2018-07-01 03:35:51 +03:00
|
|
|
require("dotenv").config();
|
|
|
|
|
|
|
|
process.on("unhandledRejection", (reason, p) => {
|
|
|
|
// tslint:disable-next-line
|
|
|
|
console.error(reason);
|
2018-08-02 03:46:29 +03:00
|
|
|
process.exit(1);
|
2018-07-01 03:35:51 +03:00
|
|
|
});
|
|
|
|
|
2018-08-03 19:25:00 +03:00
|
|
|
process.on("uncaughtException", err => {
|
|
|
|
if (err.message && err.message.startsWith("DiscordHTTPError")) {
|
|
|
|
console.error(err);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
console.error(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-07 15:39:56 +03:00
|
|
|
// Always use UTC
|
|
|
|
// This is also set for the database in knexfile
|
2018-08-02 00:48:48 +03:00
|
|
|
import moment from "moment-timezone";
|
2018-07-07 15:39:56 +03:00
|
|
|
moment.tz.setDefault("UTC");
|
|
|
|
|
2018-07-01 03:35:51 +03:00
|
|
|
import { Client } from "eris";
|
2018-07-01 04:31:24 +03:00
|
|
|
import { Knub, logger } from "knub";
|
2018-07-01 03:35:51 +03:00
|
|
|
import { BotControlPlugin } from "./plugins/BotControl";
|
|
|
|
import { ModActionsPlugin } from "./plugins/ModActions";
|
|
|
|
import { UtilityPlugin } from "./plugins/Utility";
|
2018-07-09 02:48:36 +03:00
|
|
|
import { LogsPlugin } from "./plugins/Logs";
|
2018-07-14 20:54:48 +03:00
|
|
|
import { PostPlugin } from "./plugins/Post";
|
2018-07-29 15:18:26 +03:00
|
|
|
import { ReactionRolesPlugin } from "./plugins/ReactionRoles";
|
2018-07-30 01:44:03 +03:00
|
|
|
import { CensorPlugin } from "./plugins/Censor";
|
2018-07-30 23:35:44 +03:00
|
|
|
import { PersistPlugin } from "./plugins/Persist";
|
2018-07-31 02:42:45 +03:00
|
|
|
import { SpamPlugin } from "./plugins/Spam";
|
2018-08-01 20:09:51 +03:00
|
|
|
import { LogServerPlugin } from "./plugins/LogServer";
|
2018-07-01 03:35:51 +03:00
|
|
|
import knex from "./knex";
|
|
|
|
|
|
|
|
// Run latest database migrations
|
2018-07-01 04:31:24 +03:00
|
|
|
logger.info("Running database migrations");
|
2018-07-01 03:35:51 +03:00
|
|
|
knex.migrate.latest().then(() => {
|
2018-07-31 20:58:48 +03:00
|
|
|
const client = new Client(process.env.TOKEN, {
|
|
|
|
getAllUsers: true
|
|
|
|
});
|
2018-07-31 02:42:45 +03:00
|
|
|
client.setMaxListeners(100);
|
2018-07-01 03:35:51 +03:00
|
|
|
|
|
|
|
const bot = new Knub(client, {
|
|
|
|
plugins: {
|
|
|
|
utility: UtilityPlugin,
|
2018-07-09 02:48:36 +03:00
|
|
|
mod_actions: ModActionsPlugin,
|
2018-07-14 20:54:48 +03:00
|
|
|
logs: LogsPlugin,
|
2018-07-29 15:18:26 +03:00
|
|
|
post: PostPlugin,
|
2018-07-30 01:44:03 +03:00
|
|
|
reaction_roles: ReactionRolesPlugin,
|
2018-07-30 23:35:44 +03:00
|
|
|
censor: CensorPlugin,
|
2018-07-31 02:42:45 +03:00
|
|
|
persist: PersistPlugin,
|
|
|
|
spam: SpamPlugin
|
2018-07-01 03:35:51 +03:00
|
|
|
},
|
|
|
|
globalPlugins: {
|
2018-08-01 20:09:51 +03:00
|
|
|
bot_control: BotControlPlugin,
|
|
|
|
log_server: LogServerPlugin
|
2018-07-31 19:00:17 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
options: {
|
|
|
|
getEnabledPlugins(guildId, guildConfig): string[] {
|
|
|
|
const plugins = guildConfig.plugins || {};
|
|
|
|
const keys: string[] = Array.from(this.plugins.keys());
|
|
|
|
return keys.filter(pluginName => {
|
|
|
|
return plugins[pluginName] && plugins[pluginName].enabled !== false;
|
|
|
|
});
|
|
|
|
}
|
2018-07-01 03:35:51 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-01 04:31:24 +03:00
|
|
|
logger.info("Starting the bot");
|
2018-07-01 03:35:51 +03:00
|
|
|
bot.run();
|
|
|
|
});
|