blob: 2a0702afd63e3870950824c5cdf4dd516dab5e10 [file] [log] [blame]
TheCodedProf1c3ad3c2023-01-25 17:58:36 -05001import Discord, { Client, Interaction, AutocompleteInteraction, GatewayIntentBits, Collection } from 'discord.js';
PineaFan64486c42022-12-28 09:21:04 +00002import { Logger } from "../utils/log.js";
3import Memory from "../utils/memory.js";
4import type { VerifySchema } from "../reflex/verify.js";
PineaFan538d3752023-01-12 21:48:23 +00005import { Guilds, History, ModNotes, Premium, PerformanceTest } from "../utils/database.js";
PineaFan64486c42022-12-28 09:21:04 +00006import EventScheduler from "../utils/eventScheduler.js";
7import type { RoleMenuSchema } from "../actions/roleMenu.js";
PineaFan752af462022-12-31 21:59:38 +00008import config from "../config/main.json" assert { type: "json" };
pineafan6fb3e072022-05-20 19:27:23 +01009
PineaFan64486c42022-12-28 09:21:04 +000010
11class NucleusClient extends Client {
12 logger = Logger;
PineaFan752af462022-12-31 21:59:38 +000013 config: typeof config = config;
PineaFan64486c42022-12-28 09:21:04 +000014 verify: Record<string, VerifySchema> = {};
15 roleMenu: Record<string, RoleMenuSchema> = {};
16 memory: Memory = new Memory() as Memory;
17 noLog: string[] = [];
18 database: {
19 guilds: Guilds;
20 history: History;
21 notes: ModNotes;
22 premium: Premium;
23 eventScheduler: EventScheduler;
PineaFan538d3752023-01-12 21:48:23 +000024 performanceTest: PerformanceTest;
PineaFan64486c42022-12-28 09:21:04 +000025 };
PineaFan0d06edc2023-01-17 22:10:31 +000026 preloadPage: Record<string, {command: string, argument: string}> = {}; // e.g. { channelID: { command: privacy, page: 3}}
TheCodedProff86ba092023-01-27 17:10:07 -050027 commands: Record<string, [{
PineaFandf4996f2023-01-01 14:20:06 +000028 command: Discord.SlashCommandBuilder |
29 ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder) |
30 Discord.SlashCommandSubcommandBuilder | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder) | Discord.SlashCommandSubcommandGroupBuilder | ((builder: Discord.SlashCommandSubcommandGroupBuilder) => Discord.SlashCommandSubcommandGroupBuilder),
31 callback: (interaction: Interaction) => Promise<void>,
TheCodedProff86ba092023-01-27 17:10:07 -050032 check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean,
PineaFana34d04b2023-01-03 22:05:42 +000033 autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>
TheCodedProff86ba092023-01-27 17:10:07 -050034 } | undefined,{name: string, description: string}]> = {};
TheCodedProf1c3ad3c2023-01-25 17:58:36 -050035 fetchedCommands: Collection<string, Discord.ApplicationCommand> = new Collection();
PineaFan64486c42022-12-28 09:21:04 +000036 constructor(database: typeof NucleusClient.prototype.database) {
PineaFan538d3752023-01-12 21:48:23 +000037 super({ intents: [
38 GatewayIntentBits.Guilds,
39 GatewayIntentBits.GuildMessages,
40 GatewayIntentBits.MessageContent,
41 GatewayIntentBits.GuildPresences,
42 GatewayIntentBits.GuildMembers
43 ]});
PineaFan64486c42022-12-28 09:21:04 +000044 this.database = database;
45 }
46}
47
48const client = new NucleusClient({
PineaFan100df682023-01-02 13:26:08 +000049 guilds: await new Guilds().setup(),
PineaFan64486c42022-12-28 09:21:04 +000050 history: new History(),
51 notes: new ModNotes(),
52 premium: new Premium(),
PineaFan538d3752023-01-12 21:48:23 +000053 eventScheduler: new EventScheduler(),
54 performanceTest: new PerformanceTest()
PineaFan64486c42022-12-28 09:21:04 +000055});
pineafan6fb3e072022-05-20 19:27:23 +010056
Skyler Grey75ea9172022-08-06 10:22:23 +010057export default client;
PineaFan64486c42022-12-28 09:21:04 +000058export { NucleusClient };