From 7fc069f4b9efe6c561635cb8806f3f43e780ec79 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sat, 16 Apr 2022 11:59:23 +0700 Subject: [PATCH] update sth --- src/client/websocket/WebSocketManager.js | 1 + src/structures/MessagePayload.js | 2 +- src/structures/WebEmbed.js | 4 ++++ src/util/Constants.js | 2 ++ typings/index.d.ts | 10 ++++++++-- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/client/websocket/WebSocketManager.js b/src/client/websocket/WebSocketManager.js index 7ebcda1..04bd8c5 100644 --- a/src/client/websocket/WebSocketManager.js +++ b/src/client/websocket/WebSocketManager.js @@ -352,6 +352,7 @@ class WebSocketManager extends EventEmitter { } else if (packet) { /* Debug mode */ // console.log(`Unhandled packet: ${packet.t}`, packet); + this.client.emit(Events.UNHANDLED_PACKET, packet, shard); } return true; } diff --git a/src/structures/MessagePayload.js b/src/structures/MessagePayload.js index 1521d30..a541b65 100644 --- a/src/structures/MessagePayload.js +++ b/src/structures/MessagePayload.js @@ -195,7 +195,7 @@ class MessagePayload { } const webembeds = this.options.embeds.filter( - (e) => !(e instanceof MessageEmbed), + (e) => e instanceof WebEmbed, ); this.options.embeds = this.options.embeds.filter(e => e instanceof MessageEmbed); diff --git a/src/structures/WebEmbed.js b/src/structures/WebEmbed.js index 4bbaa65..bcca214 100644 --- a/src/structures/WebEmbed.js +++ b/src/structures/WebEmbed.js @@ -21,6 +21,10 @@ class WebEmbed { */ this.hidden = data.hidden ?? false; } + /** + * @private + * @param {object} data + */ _setup(data) { /** * Type image of this embed diff --git a/src/util/Constants.js b/src/util/Constants.js index 3c94256..14f13d7 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -373,6 +373,8 @@ exports.Events = { GUILD_SCHEDULED_EVENT_USER_REMOVE: 'guildScheduledEventUserRemove', RELATIONSHIP_ADD: 'relationshipAdd', RELATIONSHIP_REMOVE: 'relationshipRemove', + /* Add */ + UNHANDLED_PACKET: 'unhandledPacket', }; exports.ShardEvents = { diff --git a/typings/index.d.ts b/typings/index.d.ts index 84c36ff..e249320 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -44,6 +44,7 @@ import { APISelectMenuComponent, APITemplateSerializedSourceGuild, APIUser, + GatewayOpcodes, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, RESTPostAPIApplicationCommandsJSONBody, @@ -4149,12 +4150,16 @@ export interface ClientEvents extends BaseClientEvents { id: Snowflake, type: RelationshipType, user: User, - ] + ]; relationshipRemove: [ id: Snowflake, type: RelationshipType, user: User, - ] + ]; + unhandledPacket: [ + packet: { op: GatewayOpcodes | number, d?: any, s?: number, t?: string }, + shard: WebSocketShard, + ]; } export interface ClientFetchInviteOptions { @@ -4407,6 +4412,7 @@ export interface ConstantsEvents { GUILD_SCHEDULED_EVENT_USER_REMOVE: 'guildScheduledEventUserRemove', RELATIONSHIP_ADD: 'relationshipAdd', RELATIONSHIP_REMOVE: 'relationshipRemove', + UNHANDLED_PACKET: 'unhandledPacket', } export interface ConstantsOpcodes {