blob: 43f8c5fdc7a530c48ac810ea72a4d330d03237c9 [file] [log] [blame]
Skyler Greyda16adf2023-03-05 10:22:12 +00001import 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";
Skyler Greyda16adf2023-03-05 10:22:12 +00005import { 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 +000010class NucleusClient extends Client {
11 logger = Logger;
PineaFan752af462022-12-31 21:59:38 +000012 config: typeof config = config;
PineaFan64486c42022-12-28 09:21:04 +000013 verify: Record<string, VerifySchema> = {};
14 roleMenu: Record<string, RoleMenuSchema> = {};
15 memory: Memory = new Memory() as Memory;
16 noLog: string[] = [];
17 database: {
18 guilds: Guilds;
19 history: History;
20 notes: ModNotes;
21 premium: Premium;
22 eventScheduler: EventScheduler;
PineaFan538d3752023-01-12 21:48:23 +000023 performanceTest: PerformanceTest;
TheCodedProfb5e9d552023-01-29 15:43:26 -050024 scanCache: ScanCache;
Skyler Greyda16adf2023-03-05 10:22:12 +000025 transcripts: Transcript;
PineaFan64486c42022-12-28 09:21:04 +000026 };
Skyler Greyda16adf2023-03-05 10:22:12 +000027 preloadPage: Record<string, { command: string; argument: string }> = {}; // e.g. { channelID: { command: privacy, page: 3}}
28 commands: Record<
29 string,
30 [
31 (
32 | {
33 command:
34 | Discord.SlashCommandBuilder
35 | ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder)
36 | Discord.SlashCommandSubcommandBuilder
37 | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder)
38 | Discord.SlashCommandSubcommandGroupBuilder
39 | ((
40 builder: Discord.SlashCommandSubcommandGroupBuilder
41 ) => Discord.SlashCommandSubcommandGroupBuilder);
42 callback: (interaction: Interaction) => Promise<void>;
43 check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean;
44 autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>;
45 }
46 | undefined
47 ),
48 { name: string; description: string }
49 ]
50 > = {};
PineaFanb0d0c242023-02-05 10:59:45 +000051 fetchedCommands = new Collection<string, Discord.ApplicationCommand>();
PineaFan64486c42022-12-28 09:21:04 +000052 constructor(database: typeof NucleusClient.prototype.database) {
TheCodedProfb7a7b992023-03-05 16:11:59 -050053 super({ intents: 3276543 });
PineaFan64486c42022-12-28 09:21:04 +000054 this.database = database;
55 }
56}
PineaFan64486c42022-12-28 09:21:04 +000057const client = new NucleusClient({
TheCodedProf85dcca82023-03-05 16:13:31 -050058 guilds: new Guilds(),
PineaFan64486c42022-12-28 09:21:04 +000059 history: new History(),
60 notes: new ModNotes(),
61 premium: new Premium(),
PineaFan538d3752023-01-12 21:48:23 +000062 eventScheduler: new EventScheduler(),
TheCodedProfb5e9d552023-01-29 15:43:26 -050063 performanceTest: new PerformanceTest(),
TheCodedProfcfe8e9a2023-02-26 17:28:09 -050064 scanCache: new ScanCache(),
65 transcripts: new Transcript()
PineaFan64486c42022-12-28 09:21:04 +000066});
pineafan6fb3e072022-05-20 19:27:23 +010067
Skyler Grey75ea9172022-08-06 10:22:23 +010068export default client;
Skyler Greyda16adf2023-03-05 10:22:12 +000069export { NucleusClient };