TravBot-v3/src/index.ts

80 lines
2.5 KiB
TypeScript
Raw Normal View History

2021-03-31 07:00:03 +00:00
import "./modules/globals";
import {Client, Permissions} from "discord.js";
import path from "path";
2020-07-25 11:01:24 +00:00
// This is here in order to make it much less of a headache to access the client from other files.
// This of course won't actually do anything until the setup process is complete and it logs in.
export const client = new Client();
import {launch} from "onion-lasers";
import setup from "./modules/setup";
import {Config, getPrefix} from "./structures";
import {toTitleCase} from "./lib";
2021-03-31 02:56:25 +00:00
// Send the login request to Discord's API and then load modules while waiting for it.
2020-07-25 11:01:24 +00:00
setup.init().then(() => {
2020-12-15 01:44:28 +00:00
client.login(Config.token).catch(setup.again);
2020-10-15 09:23:24 +00:00
});
2021-03-31 02:56:25 +00:00
// Setup the command handler.
launch(client, path.join(__dirname, "commands"), {
getPrefix,
categoryTransformer: toTitleCase,
permissionLevels: [
{
// NONE //
name: "User",
check: () => true
},
{
// MOD //
name: "Moderator",
check: (_user, member) =>
!!member &&
(member.hasPermission(Permissions.FLAGS.MANAGE_ROLES) ||
member.hasPermission(Permissions.FLAGS.MANAGE_MESSAGES) ||
member.hasPermission(Permissions.FLAGS.KICK_MEMBERS) ||
member.hasPermission(Permissions.FLAGS.BAN_MEMBERS))
},
{
// ADMIN //
name: "Administrator",
check: (_user, member) => !!member && member.hasPermission(Permissions.FLAGS.ADMINISTRATOR)
},
{
// OWNER //
name: "Server Owner",
check: (_user, member) => !!member && member.guild.ownerID === member.id
},
{
// BOT_SUPPORT //
name: "Bot Support",
check: (user) => Config.support.includes(user.id)
},
{
// BOT_ADMIN //
name: "Bot Admin",
check: (user) => Config.admins.includes(user.id)
},
{
// BOT_OWNER //
name: "Bot Owner",
check: (user) => Config.owner === user.id
}
]
});
2021-03-31 02:56:25 +00:00
// Initialize Modules //
import "./modules/ready";
2021-03-31 07:00:03 +00:00
import "./modules/presence";
2021-03-31 02:56:25 +00:00
import "./modules/lavalink";
import "./modules/emoteRegistry";
import "./modules/systemInfo";
import "./modules/intercept";
import "./modules/messageEmbed";
import "./modules/guildMemberAdd";
import "./modules/streamNotifications";
import "./modules/channelDefaults";
2021-05-08 13:32:45 +00:00
// This module must be loaded last for the dynamic event reading to work properly.
import "./modules/eventLogging";