blob: 6899b90c3d902628654f7ee7e63a0a05e56847e2 [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";
TheCodedProf35e73712023-03-10 17:35:35 -05009import { Octokit } from "octokit";
pineafan6fb3e072022-05-20 19:27:23 +010010
PineaFan64486c42022-12-28 09:21:04 +000011class 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;
Skyler Greyda16adf2023-03-05 10:22:12 +000026 transcripts: Transcript;
PineaFan64486c42022-12-28 09:21:04 +000027 };
TheCodedProf35e73712023-03-10 17:35:35 -050028 GitHub = new Octokit({ auth: config.githubPAT });
Skyler Greyda16adf2023-03-05 10:22:12 +000029 preloadPage: Record<string, { command: string; argument: string }> = {}; // e.g. { channelID: { command: privacy, page: 3}}
30 commands: Record<
31 string,
32 [
33 (
34 | {
35 command:
36 | Discord.SlashCommandBuilder
37 | ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder)
38 | Discord.SlashCommandSubcommandBuilder
39 | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder)
40 | Discord.SlashCommandSubcommandGroupBuilder
41 | ((
42 builder: Discord.SlashCommandSubcommandGroupBuilder
43 ) => Discord.SlashCommandSubcommandGroupBuilder);
44 callback: (interaction: Interaction) => Promise<void>;
45 check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean;
46 autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>;
47 }
48 | undefined
49 ),
50 { name: string; description: string }
51 ]
52 > = {};
PineaFanb0d0c242023-02-05 10:59:45 +000053 fetchedCommands = new Collection<string, Discord.ApplicationCommand>();
PineaFan64486c42022-12-28 09:21:04 +000054 constructor(database: typeof NucleusClient.prototype.database) {
TheCodedProfb7a7b992023-03-05 16:11:59 -050055 super({ intents: 3276543 });
PineaFan64486c42022-12-28 09:21:04 +000056 this.database = database;
57 }
58}
PineaFan64486c42022-12-28 09:21:04 +000059const client = new NucleusClient({
TheCodedProf85dcca82023-03-05 16:13:31 -050060 guilds: new Guilds(),
PineaFan64486c42022-12-28 09:21:04 +000061 history: new History(),
62 notes: new ModNotes(),
63 premium: new Premium(),
PineaFan538d3752023-01-12 21:48:23 +000064 eventScheduler: new EventScheduler(),
TheCodedProfb5e9d552023-01-29 15:43:26 -050065 performanceTest: new PerformanceTest(),
TheCodedProfcfe8e9a2023-02-26 17:28:09 -050066 scanCache: new ScanCache(),
67 transcripts: new Transcript()
PineaFan64486c42022-12-28 09:21:04 +000068});
pineafan6fb3e072022-05-20 19:27:23 +010069
Skyler Grey75ea9172022-08-06 10:22:23 +010070export default client;
Skyler Greyda16adf2023-03-05 10:22:12 +000071export { NucleusClient };