From 6c42168b8f084e6755c1164ad0d1b0497d969971 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Fri, 12 Nov 2021 14:44:02 +0000 Subject: [PATCH] few more cleanup refactoring --- src/bot.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index 35b78b5a8..85d4e6c4f 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -119,6 +119,7 @@ export function createBot( constants: createBotConstants(), handlers: createBotGatewayHandlers({}), enabledPlugins: new Set(), + handleDiscordPayload: options.handleDiscordPayload, }; // @ts-ignore itoh cache types plz @@ -288,7 +289,7 @@ export async function startBot(bot: Bot) { maxShards: bot.botGatewayData.shards, debug: bot.events.debug, handleDiscordPayload: - // bot.handleDiscordPayload || + bot.handleDiscordPayload ?? async function (_, data: DiscordGatewayPayload, shardId: number) { // TRIGGER RAW EVENT bot.events.raw(bot as Bot, data, shardId); @@ -385,18 +386,18 @@ export function createGatewayManager( buckets: new Collection(), utf8decoder: new TextDecoder(), - spawnShards, - createShard, - identify, - heartbeat, + spawnShards: options.spawnShards ?? spawnShards, + createShard: options.createShard ?? createShard, + identify: options.identify ?? identify, + heartbeat: options.heartbeat ?? heartbeat, tellClusterToIdentify, debug: options.debug || function () {}, - resharder, - handleOnMessage, - processGatewayQueue, - closeWS, - sendShardMessage, - resume, + resharder: options.resharder ?? resharder, + handleOnMessage: options.handleOnMessage ?? handleOnMessage, + processGatewayQueue: options.processGatewayQueue ?? processGatewayQueue, + closeWS: options.closeWS ?? closeWS, + sendShardMessage: options.sendShardMessage ?? sendShardMessage, + resume: options.resume ?? resume, handleDiscordPayload: options.handleDiscordPayload, }; } @@ -421,6 +422,7 @@ export interface CreateBotOptions { intents: (keyof typeof DiscordGatewayIntents)[]; botGatewayData?: GetGatewayBot; rest?: Omit; + handleDiscordPayload?: GatewayManager["handleDiscordPayload"]; cache: C; } @@ -455,6 +457,7 @@ export interface Bot { constants: ReturnType; cache: C; enabledPlugins: Set; + handleDiscordPayload?: GatewayManager["handleDiscordPayload"], } export interface Helpers {