Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [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"; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 5 | import { Guilds, History, ModNotes, Premium, PerformanceTest, ScanCache, Transcript } 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 | class NucleusClient extends Client { |
| 11 | logger = Logger; |
PineaFan | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 12 | config: typeof config = config; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 13 | verify: Record<string, VerifySchema> = {}; |
| 14 | roleMenu: Record<string, RoleMenuSchema> = {}; |
| 15 | memory: Memory = new Memory() as Memory; |
| 16 | noLog: string[] = []; |
| 17 | database: { |
| 18 | guilds: Guilds; |
| 19 | history: History; |
| 20 | notes: ModNotes; |
| 21 | premium: Premium; |
| 22 | eventScheduler: EventScheduler; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 23 | performanceTest: PerformanceTest; |
TheCodedProf | b5e9d55 | 2023-01-29 15:43:26 -0500 | [diff] [blame] | 24 | scanCache: ScanCache; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 25 | transcripts: Transcript; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 26 | }; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 27 | preloadPage: Record<string, { command: string; argument: string }> = {}; // e.g. { channelID: { command: privacy, page: 3}} |
| 28 | commands: Record< |
| 29 | string, |
| 30 | [ |
| 31 | ( |
| 32 | | { |
| 33 | command: |
| 34 | | Discord.SlashCommandBuilder |
| 35 | | ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder) |
| 36 | | Discord.SlashCommandSubcommandBuilder |
| 37 | | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder) |
| 38 | | Discord.SlashCommandSubcommandGroupBuilder |
| 39 | | (( |
| 40 | builder: Discord.SlashCommandSubcommandGroupBuilder |
| 41 | ) => Discord.SlashCommandSubcommandGroupBuilder); |
| 42 | callback: (interaction: Interaction) => Promise<void>; |
| 43 | check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean; |
| 44 | autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>; |
| 45 | } |
| 46 | | undefined |
| 47 | ), |
| 48 | { name: string; description: string } |
| 49 | ] |
| 50 | > = {}; |
PineaFan | b0d0c24 | 2023-02-05 10:59:45 +0000 | [diff] [blame] | 51 | fetchedCommands = new Collection<string, Discord.ApplicationCommand>(); |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 52 | constructor(database: typeof NucleusClient.prototype.database) { |
TheCodedProf | b7a7b99 | 2023-03-05 16:11:59 -0500 | [diff] [blame] | 53 | super({ intents: 3276543 }); |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 54 | this.database = database; |
| 55 | } |
| 56 | } |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 57 | const client = new NucleusClient({ |
TheCodedProf | f8ef794 | 2023-03-03 15:32:32 -0500 | [diff] [blame] | 58 | guilds: await new Guilds(), |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 59 | history: new History(), |
| 60 | notes: new ModNotes(), |
| 61 | premium: new Premium(), |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 62 | eventScheduler: new EventScheduler(), |
TheCodedProf | b5e9d55 | 2023-01-29 15:43:26 -0500 | [diff] [blame] | 63 | performanceTest: new PerformanceTest(), |
TheCodedProf | cfe8e9a | 2023-02-26 17:28:09 -0500 | [diff] [blame] | 64 | scanCache: new ScanCache(), |
| 65 | transcripts: new Transcript() |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 66 | }); |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 67 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 68 | export default client; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 69 | export { NucleusClient }; |