TravBot-v3/src/index.ts

92 lines
3.0 KiB
TypeScript
Raw Permalink Normal View History

2021-03-31 07:00:03 +00:00
import "./modules/globals";
2021-05-17 22:12:14 +00:00
import {Client, Permissions, Intents} 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({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Intents.FLAGS.GUILD_VOICE_STATES,
Intents.FLAGS.GUILD_PRESENCES,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.DIRECT_MESSAGES
]
});
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 &&
2021-05-17 22:12:14 +00:00
(member.permissions.has(Permissions.FLAGS.MANAGE_ROLES) ||
member.permissions.has(Permissions.FLAGS.MANAGE_MESSAGES) ||
member.permissions.has(Permissions.FLAGS.KICK_MEMBERS) ||
member.permissions.has(Permissions.FLAGS.BAN_MEMBERS))
},
{
// ADMIN //
name: "Administrator",
2021-05-17 22:12:14 +00:00
check: (_user, member) => !!member && member.permissions.has(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";
// TODO: Reimplement entire music system, contact Sink
// import "./modules/lavalink";
2021-03-31 02:56:25 +00:00
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";