TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 1 | import Discord, { Client, Interaction, AutocompleteInteraction, Collection } from 'discord.js'; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 2 | import { Logger } from "../utils/log.js"; |
| 3 | import Memory from "../utils/memory.js"; |
| 4 | import type { VerifySchema } from "../reflex/verify.js"; |
TheCodedProf | b5e9d55 | 2023-01-29 15:43:26 -0500 | [diff] [blame] | 5 | import { Guilds, History, ModNotes, Premium, PerformanceTest, ScanCache } from "../utils/database.js"; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 6 | import EventScheduler from "../utils/eventScheduler.js"; |
| 7 | import type { RoleMenuSchema } from "../actions/roleMenu.js"; |
pineafan | a2e39c7 | 2023-02-21 18:37:32 +0000 | [diff] [blame] | 8 | import config from "../config/main.js"; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 9 | |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 10 | |
| 11 | class NucleusClient extends Client { |
| 12 | logger = Logger; |
PineaFan | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 13 | config: typeof config = config; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 14 | 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; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 24 | performanceTest: PerformanceTest; |
TheCodedProf | b5e9d55 | 2023-01-29 15:43:26 -0500 | [diff] [blame] | 25 | scanCache: ScanCache; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 26 | }; |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 27 | preloadPage: Record<string, {command: string, argument: string}> = {}; // e.g. { channelID: { command: privacy, page: 3}} |
TheCodedProf | f86ba09 | 2023-01-27 17:10:07 -0500 | [diff] [blame] | 28 | commands: Record<string, [{ |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 29 | 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>, |
TheCodedProf | f86ba09 | 2023-01-27 17:10:07 -0500 | [diff] [blame] | 33 | check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean, |
PineaFan | a34d04b | 2023-01-03 22:05:42 +0000 | [diff] [blame] | 34 | autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]> |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 35 | } | undefined, {name: string, description: string}]> = {}; |
PineaFan | b0d0c24 | 2023-02-05 10:59:45 +0000 | [diff] [blame] | 36 | fetchedCommands = new Collection<string, Discord.ApplicationCommand>(); |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 37 | constructor(database: typeof NucleusClient.prototype.database) { |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 38 | super({ intents: 0b1100011011011111111111}); |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 39 | this.database = database; |
| 40 | } |
| 41 | } |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 42 | const client = new NucleusClient({ |
PineaFan | 100df68 | 2023-01-02 13:26:08 +0000 | [diff] [blame] | 43 | guilds: await new Guilds().setup(), |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 44 | history: new History(), |
| 45 | notes: new ModNotes(), |
| 46 | premium: new Premium(), |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 47 | eventScheduler: new EventScheduler(), |
TheCodedProf | b5e9d55 | 2023-01-29 15:43:26 -0500 | [diff] [blame] | 48 | performanceTest: new PerformanceTest(), |
| 49 | scanCache: new ScanCache() |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 50 | }); |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 51 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 52 | export default client; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 53 | export { NucleusClient }; |