blob: 2e2baa6220cebad2601d9af16320acc7d043aba6 [file] [log] [blame]
PineaFand471ccd2023-01-26 20:48:40 +00001import { ApplicationCommand, ApplicationCommandResolvable, DataManager } from 'discord.js';
TheCodedProf1c3ad3c2023-01-25 17:58:36 -05002import Discord, { Client, Interaction, AutocompleteInteraction, GatewayIntentBits, Collection } from 'discord.js';
PineaFan64486c42022-12-28 09:21:04 +00003import { Logger } from "../utils/log.js";
4import Memory from "../utils/memory.js";
5import type { VerifySchema } from "../reflex/verify.js";
PineaFan538d3752023-01-12 21:48:23 +00006import { Guilds, History, ModNotes, Premium, PerformanceTest } from "../utils/database.js";
PineaFan64486c42022-12-28 09:21:04 +00007import EventScheduler from "../utils/eventScheduler.js";
8import type { RoleMenuSchema } from "../actions/roleMenu.js";
PineaFan752af462022-12-31 21:59:38 +00009import config from "../config/main.json" assert { type: "json" };
pineafan6fb3e072022-05-20 19:27:23 +010010
PineaFan64486c42022-12-28 09:21:04 +000011
12class NucleusClient extends Client {
13 logger = Logger;
PineaFan752af462022-12-31 21:59:38 +000014 config: typeof config = config;
PineaFan64486c42022-12-28 09:21:04 +000015 verify: Record<string, VerifySchema> = {};
16 roleMenu: Record<string, RoleMenuSchema> = {};
17 memory: Memory = new Memory() as Memory;
18 noLog: string[] = [];
19 database: {
20 guilds: Guilds;
21 history: History;
22 notes: ModNotes;
23 premium: Premium;
24 eventScheduler: EventScheduler;
PineaFan538d3752023-01-12 21:48:23 +000025 performanceTest: PerformanceTest;
PineaFan64486c42022-12-28 09:21:04 +000026 };
PineaFand471ccd2023-01-26 20:48:40 +000027 commandList?: Discord.Collection<string, Discord.ApplicationCommand>;
PineaFan0d06edc2023-01-17 22:10:31 +000028 preloadPage: Record<string, {command: string, argument: string}> = {}; // e.g. { channelID: { command: privacy, page: 3}}
PineaFandf4996f2023-01-01 14:20:06 +000029 commands: Record<string, {
30 command: Discord.SlashCommandBuilder |
31 ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder) |
32 Discord.SlashCommandSubcommandBuilder | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder) | Discord.SlashCommandSubcommandGroupBuilder | ((builder: Discord.SlashCommandSubcommandGroupBuilder) => Discord.SlashCommandSubcommandGroupBuilder),
33 callback: (interaction: Interaction) => Promise<void>,
PineaFana34d04b2023-01-03 22:05:42 +000034 check: (interaction: Interaction) => Promise<boolean> | boolean,
35 autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>
PineaFandf4996f2023-01-01 14:20:06 +000036 }> = {};
TheCodedProf1c3ad3c2023-01-25 17:58:36 -050037 fetchedCommands: Collection<string, Discord.ApplicationCommand> = new Collection();
PineaFan64486c42022-12-28 09:21:04 +000038 constructor(database: typeof NucleusClient.prototype.database) {
PineaFan538d3752023-01-12 21:48:23 +000039 super({ intents: [
40 GatewayIntentBits.Guilds,
41 GatewayIntentBits.GuildMessages,
42 GatewayIntentBits.MessageContent,
43 GatewayIntentBits.GuildPresences,
44 GatewayIntentBits.GuildMembers
45 ]});
PineaFan64486c42022-12-28 09:21:04 +000046 this.database = database;
47 }
48}
49
50const client = new NucleusClient({
PineaFan100df682023-01-02 13:26:08 +000051 guilds: await new Guilds().setup(),
PineaFan64486c42022-12-28 09:21:04 +000052 history: new History(),
53 notes: new ModNotes(),
54 premium: new Premium(),
PineaFan538d3752023-01-12 21:48:23 +000055 eventScheduler: new EventScheduler(),
56 performanceTest: new PerformanceTest()
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 };