From c4abe276940997f18cd4f8bc5ae80e58fae6e6d6 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Thu, 16 Feb 2023 11:55:35 +0700 Subject: [PATCH] feat: Update Gateway Opcodes --- src/client/websocket/handlers/GUILD_CREATE.js | 2 +- src/client/websocket/handlers/READY.js | 2 +- src/managers/GuildMemberManager.js | 4 ++-- src/util/Constants.js | 15 ++++++++++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/client/websocket/handlers/GUILD_CREATE.js b/src/client/websocket/handlers/GUILD_CREATE.js index 58f704c..87fa249 100644 --- a/src/client/websocket/handlers/GUILD_CREATE.js +++ b/src/client/websocket/handlers/GUILD_CREATE.js @@ -6,7 +6,7 @@ const { Events, Opcodes, Status } = require('../../../util/Constants'); const run = (client, guild) => { if (!guild.large) return; client.ws.broadcast({ - op: Opcodes.LAZY_REQUEST, + op: Opcodes.GUILD_SUBSCRIPTIONS, d: { guild_id: guild.id, typing: true, diff --git a/src/client/websocket/handlers/READY.js b/src/client/websocket/handlers/READY.js index beec814..7d0964c 100644 --- a/src/client/websocket/handlers/READY.js +++ b/src/client/websocket/handlers/READY.js @@ -154,7 +154,7 @@ module.exports = async (client, { d: data }, shard) => { for (const guild of largeGuilds) { await client.sleep(client.options.messageCreateEventGuildTimeout); client.ws.broadcast({ - op: Opcodes.LAZY_REQUEST, + op: Opcodes.GUILD_SUBSCRIPTIONS, d: { guild_id: guild.id, typing: true, diff --git a/src/managers/GuildMemberManager.js b/src/managers/GuildMemberManager.js index a029fb5..4d0abd7 100644 --- a/src/managers/GuildMemberManager.js +++ b/src/managers/GuildMemberManager.js @@ -556,7 +556,7 @@ class GuildMemberManager extends CachedManager { if (type == 'INVALIDATE' && offset > 100) { if (retry < retryMax) { this.guild.shard.send({ - op: Opcodes.LAZY_REQUEST, + op: Opcodes.GUILD_SUBSCRIPTIONS, d: { guild_id: this.guild.id, typing: true, @@ -594,7 +594,7 @@ class GuildMemberManager extends CachedManager { this.client.incrementMaxListeners(); this.client.on(Events.GUILD_MEMBER_LIST_UPDATE, handler); this.guild.shard.send({ - op: Opcodes.LAZY_REQUEST, + op: Opcodes.GUILD_SUBSCRIPTIONS, d: { guild_id: this.guild.id, typing: true, diff --git a/src/util/Constants.js b/src/util/Constants.js index db3a646..84742df 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -273,7 +273,7 @@ exports.Status = { * * HEARTBEAT_ACK: 11 * * GUILD_SYNC: 12 [Unused] * * DM_UPDATE: 13 # Send => used to get dm features - * * LAZY_REQUEST: 14 # Send => discord responds back with GUILD_MEMBER_LIST_UPDATE type SYNC... + * * GUILD_SUBSCRIPTIONS: 14 # Send => discord responds back with GUILD_MEMBER_LIST_UPDATE type SYNC... * * LOBBY_CONNECT: 15 * * LOBBY_DISCONNECT: 16 * * LOBBY_VOICE_STATE_UPDATE: 17 # Receive @@ -283,6 +283,11 @@ exports.Status = { * * STREAM_PING: 21 # Send * * STREAM_SET_PAUSED: 22 * * REQUEST_APPLICATION_COMMANDS: 24 + * * EMBEDDED_ACTIVITY_LAUNCH: 25 + * * EMBEDDED_ACTIVITY_CLOSE: 26 + * * EMBEDDED_ACTIVITY_UPDATE: 27 + * * REQUEST_FORUM_UNREADS: 28 + * * REMOTE_COMMAND: 29 * @typedef {Object} Opcodes */ exports.Opcodes = { @@ -299,9 +304,8 @@ exports.Opcodes = { HELLO: 10, // # Receive => sent immediately after connecting, contains heartbeat and server debug information HEARTBEAT_ACK: 11, // # Sent => immediately following a client heartbeat that was received GUILD_SYNC: 12, // # Receive => guild_sync but not used anymore - // Add some opcode from Discum: https://github.com/Merubokkusu/Discord-S.C.U.M/blob/master/discum/gateway/gateway.py#L56 DM_UPDATE: 13, // # Send => used to get dm features - LAZY_REQUEST: 14, // # Send => discord responds back with GUILD_MEMBER_LIST_UPDATE type SYNC... + GUILD_SUBSCRIPTIONS: 14, // # Send => discord responds back with GUILD_MEMBER_LIST_UPDATE type SYNC... LOBBY_CONNECT: 15, LOBBY_DISCONNECT: 16, LOBBY_VOICE_STATE_UPDATE: 17, // # Receive @@ -311,6 +315,11 @@ exports.Opcodes = { STREAM_PING: 21, // # Send STREAM_SET_PAUSED: 22, REQUEST_APPLICATION_COMMANDS: 24, // # Send => request application/bot cmds (user, message, and slash cmds) + EMBEDDED_ACTIVITY_LAUNCH: 25, + EMBEDDED_ACTIVITY_CLOSE: 26, + EMBEDDED_ACTIVITY_UPDATE: 27, + REQUEST_FORUM_UNREADS: 28, + REMOTE_COMMAND: 29, }; /**