blob: 43cbe11e6709f0f0e867860834a9211dc5b446eb [file] [log] [blame]
PineaFan538d3752023-01-12 21:48:23 +00001import Discord, { Client, Interaction, AutocompleteInteraction, GatewayIntentBits } 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";
PineaFan538d3752023-01-12 21:48:23 +00005import { Guilds, History, ModNotes, Premium, PerformanceTest } 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;
PineaFan64486c42022-12-28 09:21:04 +000025 };
PineaFandf4996f2023-01-01 14:20:06 +000026 commands: Record<string, {
27 command: Discord.SlashCommandBuilder |
28 ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder) |
29 Discord.SlashCommandSubcommandBuilder | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder) | Discord.SlashCommandSubcommandGroupBuilder | ((builder: Discord.SlashCommandSubcommandGroupBuilder) => Discord.SlashCommandSubcommandGroupBuilder),
30 callback: (interaction: Interaction) => Promise<void>,
PineaFana34d04b2023-01-03 22:05:42 +000031 check: (interaction: Interaction) => Promise<boolean> | boolean,
32 autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>
PineaFandf4996f2023-01-01 14:20:06 +000033 }> = {};
PineaFan64486c42022-12-28 09:21:04 +000034
35 constructor(database: typeof NucleusClient.prototype.database) {
PineaFan538d3752023-01-12 21:48:23 +000036 super({ intents: [
37 GatewayIntentBits.Guilds,
38 GatewayIntentBits.GuildMessages,
39 GatewayIntentBits.MessageContent,
40 GatewayIntentBits.GuildPresences,
41 GatewayIntentBits.GuildMembers
42 ]});
PineaFan64486c42022-12-28 09:21:04 +000043 this.database = database;
44 }
45}
46
47const client = new NucleusClient({
PineaFan100df682023-01-02 13:26:08 +000048 guilds: await new Guilds().setup(),
PineaFan64486c42022-12-28 09:21:04 +000049 history: new History(),
50 notes: new ModNotes(),
51 premium: new Premium(),
PineaFan538d3752023-01-12 21:48:23 +000052 eventScheduler: new EventScheduler(),
53 performanceTest: new PerformanceTest()
PineaFan64486c42022-12-28 09:21:04 +000054});
pineafan6fb3e072022-05-20 19:27:23 +010055
Skyler Grey75ea9172022-08-06 10:22:23 +010056export default client;
PineaFan64486c42022-12-28 09:21:04 +000057export { NucleusClient };