blob: 00f8c0505656f68589ea7d2eead2ea09e7b28e8a [file] [log] [blame]
TheCodedProf6ec331b2023-02-20 12:13:06 -05001import Discord, { Client, Interaction, AutocompleteInteraction, 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";
TheCodedProfcfe8e9a2023-02-26 17:28:09 -05005import { Guilds, History, ModNotes, Premium, PerformanceTest, ScanCache, Transcript } from "../utils/database.js";
PineaFan64486c42022-12-28 09:21:04 +00006import EventScheduler from "../utils/eventScheduler.js";
7import type { RoleMenuSchema } from "../actions/roleMenu.js";
pineafana2e39c72023-02-21 18:37:32 +00008import config from "../config/main.js";
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;
TheCodedProfb5e9d552023-01-29 15:43:26 -050025 scanCache: ScanCache;
TheCodedProfcfe8e9a2023-02-26 17:28:09 -050026 transcripts: Transcript
PineaFan64486c42022-12-28 09:21:04 +000027 };
PineaFan0d06edc2023-01-17 22:10:31 +000028 preloadPage: Record<string, {command: string, argument: string}> = {}; // e.g. { channelID: { command: privacy, page: 3}}
TheCodedProff86ba092023-01-27 17:10:07 -050029 commands: Record<string, [{
PineaFandf4996f2023-01-01 14:20:06 +000030 command: Discord.SlashCommandBuilder |
31 ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder) |
32 Discord.SlashCommandSubcommandBuilder | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder) | Discord.SlashCommandSubcommandGroupBuilder | ((builder: Discord.SlashCommandSubcommandGroupBuilder) => Discord.SlashCommandSubcommandGroupBuilder),
33 callback: (interaction: Interaction) => Promise<void>,
TheCodedProff86ba092023-01-27 17:10:07 -050034 check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean,
PineaFana34d04b2023-01-03 22:05:42 +000035 autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>
TheCodedProf94ff6de2023-02-22 17:47:26 -050036 } | undefined, {name: string, description: string}]> = {};
PineaFanb0d0c242023-02-05 10:59:45 +000037 fetchedCommands = new Collection<string, Discord.ApplicationCommand>();
PineaFan64486c42022-12-28 09:21:04 +000038 constructor(database: typeof NucleusClient.prototype.database) {
TheCodedProf6ec331b2023-02-20 12:13:06 -050039 super({ intents: 0b1100011011011111111111});
PineaFan64486c42022-12-28 09:21:04 +000040 this.database = database;
41 }
42}
PineaFan64486c42022-12-28 09:21:04 +000043const client = new NucleusClient({
PineaFan100df682023-01-02 13:26:08 +000044 guilds: await new Guilds().setup(),
PineaFan64486c42022-12-28 09:21:04 +000045 history: new History(),
46 notes: new ModNotes(),
47 premium: new Premium(),
PineaFan538d3752023-01-12 21:48:23 +000048 eventScheduler: new EventScheduler(),
TheCodedProfb5e9d552023-01-29 15:43:26 -050049 performanceTest: new PerformanceTest(),
TheCodedProfcfe8e9a2023-02-26 17:28:09 -050050 scanCache: new ScanCache(),
51 transcripts: new Transcript()
PineaFan64486c42022-12-28 09:21:04 +000052});
pineafan6fb3e072022-05-20 19:27:23 +010053
Skyler Grey75ea9172022-08-06 10:22:23 +010054export default client;
PineaFan64486c42022-12-28 09:21:04 +000055export { NucleusClient };