PineaFan | d471ccd | 2023-01-26 20:48:40 +0000 | [diff] [blame^] | 1 | import { ApplicationCommand, ApplicationCommandResolvable, DataManager } from 'discord.js'; |
TheCodedProf | 1c3ad3c | 2023-01-25 17:58:36 -0500 | [diff] [blame] | 2 | import Discord, { Client, Interaction, AutocompleteInteraction, GatewayIntentBits, Collection } from 'discord.js'; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 3 | import { Logger } from "../utils/log.js"; |
| 4 | import Memory from "../utils/memory.js"; |
| 5 | import type { VerifySchema } from "../reflex/verify.js"; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 6 | import { Guilds, History, ModNotes, Premium, PerformanceTest } from "../utils/database.js"; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 7 | import EventScheduler from "../utils/eventScheduler.js"; |
| 8 | import type { RoleMenuSchema } from "../actions/roleMenu.js"; |
PineaFan | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 9 | import config from "../config/main.json" assert { type: "json" }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 10 | |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 11 | |
| 12 | class NucleusClient extends Client { |
| 13 | logger = Logger; |
PineaFan | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 14 | config: typeof config = config; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 15 | 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; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 25 | performanceTest: PerformanceTest; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 26 | }; |
PineaFan | d471ccd | 2023-01-26 20:48:40 +0000 | [diff] [blame^] | 27 | commandList?: Discord.Collection<string, Discord.ApplicationCommand>; |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 28 | 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] | 29 | 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>, |
PineaFan | a34d04b | 2023-01-03 22:05:42 +0000 | [diff] [blame] | 34 | check: (interaction: Interaction) => Promise<boolean> | boolean, |
| 35 | autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]> |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 36 | }> = {}; |
TheCodedProf | 1c3ad3c | 2023-01-25 17:58:36 -0500 | [diff] [blame] | 37 | fetchedCommands: Collection<string, Discord.ApplicationCommand> = new Collection(); |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 38 | constructor(database: typeof NucleusClient.prototype.database) { |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 39 | super({ intents: [ |
| 40 | GatewayIntentBits.Guilds, |
| 41 | GatewayIntentBits.GuildMessages, |
| 42 | GatewayIntentBits.MessageContent, |
| 43 | GatewayIntentBits.GuildPresences, |
| 44 | GatewayIntentBits.GuildMembers |
| 45 | ]}); |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 46 | this.database = database; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | const client = new NucleusClient({ |
PineaFan | 100df68 | 2023-01-02 13:26:08 +0000 | [diff] [blame] | 51 | guilds: await new Guilds().setup(), |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 52 | history: new History(), |
| 53 | notes: new ModNotes(), |
| 54 | premium: new Premium(), |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 55 | eventScheduler: new EventScheduler(), |
| 56 | performanceTest: new PerformanceTest() |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 57 | }); |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 58 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 59 | export default client; |
PineaFan | 64486c4 | 2022-12-28 09:21:04 +0000 | [diff] [blame] | 60 | export { NucleusClient }; |