TheCodedProf | 1c3ad3c | 2023-01-25 17:58:36 -0500 | [diff] [blame^] | 1 | import Discord, { Client, Interaction, AutocompleteInteraction, GatewayIntentBits, 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"; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 5 | import { Guilds, History, ModNotes, Premium, PerformanceTest } 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 | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 8 | import config from "../config/main.json" assert { type: "json" }; |
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; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 25 | }; |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 26 | preloadPage: Record<string, {command: string, argument: string}> = {}; // e.g. { channelID: { command: privacy, page: 3}} |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 27 | commands: Record<string, { |
| 28 | command: Discord.SlashCommandBuilder | |
| 29 | ((builder: Discord.SlashCommandBuilder) => Discord.SlashCommandBuilder) | |
| 30 | Discord.SlashCommandSubcommandBuilder | ((builder: Discord.SlashCommandSubcommandBuilder) => Discord.SlashCommandSubcommandBuilder) | Discord.SlashCommandSubcommandGroupBuilder | ((builder: Discord.SlashCommandSubcommandGroupBuilder) => Discord.SlashCommandSubcommandGroupBuilder), |
| 31 | callback: (interaction: Interaction) => Promise<void>, |
PineaFan | a34d04b | 2023-01-03 22:05:42 +0000 | [diff] [blame] | 32 | check: (interaction: Interaction) => Promise<boolean> | boolean, |
| 33 | autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]> |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 34 | }> = {}; |
TheCodedProf | 1c3ad3c | 2023-01-25 17:58:36 -0500 | [diff] [blame^] | 35 | fetchedCommands: Collection<string, Discord.ApplicationCommand> = new Collection(); |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 36 | constructor(database: typeof NucleusClient.prototype.database) { |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 37 | super({ intents: [ |
| 38 | GatewayIntentBits.Guilds, |
| 39 | GatewayIntentBits.GuildMessages, |
| 40 | GatewayIntentBits.MessageContent, |
| 41 | GatewayIntentBits.GuildPresences, |
| 42 | GatewayIntentBits.GuildMembers |
| 43 | ]}); |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 44 | this.database = database; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | const client = new NucleusClient({ |
PineaFan | 100df68 | 2023-01-02 13:26:08 +0000 | [diff] [blame] | 49 | guilds: await new Guilds().setup(), |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 50 | history: new History(), |
| 51 | notes: new ModNotes(), |
| 52 | premium: new Premium(), |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 53 | eventScheduler: new EventScheduler(), |
| 54 | performanceTest: new PerformanceTest() |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 55 | }); |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 56 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 57 | export default client; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 58 | export { NucleusClient }; |