blob: 41cdbca585800410bc53a2c06506cf48f862a700 [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";
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";
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;
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[]>
TheCodedProff86ba092023-01-27 17:10:07 -050035 } | undefined,{name: string, description: string}]> = {};
TheCodedProf1c3ad3c2023-01-25 17:58:36 -050036 fetchedCommands: Collection<string, Discord.ApplicationCommand> = new Collection();
PineaFan64486c42022-12-28 09:21:04 +000037 constructor(database: typeof NucleusClient.prototype.database) {
PineaFan538d3752023-01-12 21:48:23 +000038 super({ intents: [
39 GatewayIntentBits.Guilds,
40 GatewayIntentBits.GuildMessages,
41 GatewayIntentBits.MessageContent,
42 GatewayIntentBits.GuildPresences,
43 GatewayIntentBits.GuildMembers
44 ]});
PineaFan64486c42022-12-28 09:21:04 +000045 this.database = database;
46 }
47}
48
49const client = new NucleusClient({
PineaFan100df682023-01-02 13:26:08 +000050 guilds: await new Guilds().setup(),
PineaFan64486c42022-12-28 09:21:04 +000051 history: new History(),
52 notes: new ModNotes(),
53 premium: new Premium(),
PineaFan538d3752023-01-12 21:48:23 +000054 eventScheduler: new EventScheduler(),
TheCodedProfb5e9d552023-01-29 15:43:26 -050055 performanceTest: new PerformanceTest(),
56 scanCache: new ScanCache()
PineaFan64486c42022-12-28 09:21:04 +000057});
pineafan6fb3e072022-05-20 19:27:23 +010058
Skyler Grey75ea9172022-08-06 10:22:23 +010059export default client;
PineaFan64486c42022-12-28 09:21:04 +000060export { NucleusClient };