blob: 857fb1ddaa09dc176cbb594b52c31f66b4f990c2 [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";
TheCodedProfb5e9d552023-01-29 15:43:26 -05005import { Guilds, History, ModNotes, Premium, PerformanceTest, ScanCache } 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;
PineaFan64486c42022-12-28 09:21:04 +000026 };
PineaFan0d06edc2023-01-17 22:10:31 +000027 preloadPage: Record<string, {command: string, argument: string}> = {}; // e.g. { channelID: { command: privacy, page: 3}}
TheCodedProff86ba092023-01-27 17:10:07 -050028 commands: Record<string, [{
PineaFandf4996f2023-01-01 14:20:06 +000029 command: Discord.SlashCommandBuilder |
30 ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder) |
31 Discord.SlashCommandSubcommandBuilder | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder) | Discord.SlashCommandSubcommandGroupBuilder | ((builder: Discord.SlashCommandSubcommandGroupBuilder) => Discord.SlashCommandSubcommandGroupBuilder),
32 callback: (interaction: Interaction) => Promise<void>,
TheCodedProff86ba092023-01-27 17:10:07 -050033 check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean,
PineaFana34d04b2023-01-03 22:05:42 +000034 autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>
TheCodedProf94ff6de2023-02-22 17:47:26 -050035 } | undefined, {name: string, description: string}]> = {};
PineaFanb0d0c242023-02-05 10:59:45 +000036 fetchedCommands = new Collection<string, Discord.ApplicationCommand>();
PineaFan64486c42022-12-28 09:21:04 +000037 constructor(database: typeof NucleusClient.prototype.database) {
TheCodedProf6ec331b2023-02-20 12:13:06 -050038 super({ intents: 0b1100011011011111111111});
PineaFan64486c42022-12-28 09:21:04 +000039 this.database = database;
40 }
41}
PineaFan64486c42022-12-28 09:21:04 +000042const client = new NucleusClient({
PineaFan100df682023-01-02 13:26:08 +000043 guilds: await new Guilds().setup(),
PineaFan64486c42022-12-28 09:21:04 +000044 history: new History(),
45 notes: new ModNotes(),
46 premium: new Premium(),
PineaFan538d3752023-01-12 21:48:23 +000047 eventScheduler: new EventScheduler(),
TheCodedProfb5e9d552023-01-29 15:43:26 -050048 performanceTest: new PerformanceTest(),
49 scanCache: new ScanCache()
PineaFan64486c42022-12-28 09:21:04 +000050});
pineafan6fb3e072022-05-20 19:27:23 +010051
Skyler Grey75ea9172022-08-06 10:22:23 +010052export default client;
PineaFan64486c42022-12-28 09:21:04 +000053export { NucleusClient };