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