feat: Update Gateway Opcodes

This commit is contained in:
Elysia 2023-02-16 11:55:35 +07:00
parent e683819cf0
commit c4abe27694
4 changed files with 16 additions and 7 deletions

View File

@ -6,7 +6,7 @@ const { Events, Opcodes, Status } = require('../../../util/Constants');
const run = (client, guild) => { const run = (client, guild) => {
if (!guild.large) return; if (!guild.large) return;
client.ws.broadcast({ client.ws.broadcast({
op: Opcodes.LAZY_REQUEST, op: Opcodes.GUILD_SUBSCRIPTIONS,
d: { d: {
guild_id: guild.id, guild_id: guild.id,
typing: true, typing: true,

View File

@ -154,7 +154,7 @@ module.exports = async (client, { d: data }, shard) => {
for (const guild of largeGuilds) { for (const guild of largeGuilds) {
await client.sleep(client.options.messageCreateEventGuildTimeout); await client.sleep(client.options.messageCreateEventGuildTimeout);
client.ws.broadcast({ client.ws.broadcast({
op: Opcodes.LAZY_REQUEST, op: Opcodes.GUILD_SUBSCRIPTIONS,
d: { d: {
guild_id: guild.id, guild_id: guild.id,
typing: true, typing: true,

View File

@ -556,7 +556,7 @@ class GuildMemberManager extends CachedManager {
if (type == 'INVALIDATE' && offset > 100) { if (type == 'INVALIDATE' && offset > 100) {
if (retry < retryMax) { if (retry < retryMax) {
this.guild.shard.send({ this.guild.shard.send({
op: Opcodes.LAZY_REQUEST, op: Opcodes.GUILD_SUBSCRIPTIONS,
d: { d: {
guild_id: this.guild.id, guild_id: this.guild.id,
typing: true, typing: true,
@ -594,7 +594,7 @@ class GuildMemberManager extends CachedManager {
this.client.incrementMaxListeners(); this.client.incrementMaxListeners();
this.client.on(Events.GUILD_MEMBER_LIST_UPDATE, handler); this.client.on(Events.GUILD_MEMBER_LIST_UPDATE, handler);
this.guild.shard.send({ this.guild.shard.send({
op: Opcodes.LAZY_REQUEST, op: Opcodes.GUILD_SUBSCRIPTIONS,
d: { d: {
guild_id: this.guild.id, guild_id: this.guild.id,
typing: true, typing: true,

View File

@ -273,7 +273,7 @@ exports.Status = {
* * HEARTBEAT_ACK: 11 * * HEARTBEAT_ACK: 11
* * GUILD_SYNC: 12 [Unused] * * GUILD_SYNC: 12 [Unused]
* * DM_UPDATE: 13 # Send => used to get dm features * * 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_CONNECT: 15
* * LOBBY_DISCONNECT: 16 * * LOBBY_DISCONNECT: 16
* * LOBBY_VOICE_STATE_UPDATE: 17 # Receive * * LOBBY_VOICE_STATE_UPDATE: 17 # Receive
@ -283,6 +283,11 @@ exports.Status = {
* * STREAM_PING: 21 # Send * * STREAM_PING: 21 # Send
* * STREAM_SET_PAUSED: 22 * * STREAM_SET_PAUSED: 22
* * REQUEST_APPLICATION_COMMANDS: 24 * * 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<string, number>} Opcodes * @typedef {Object<string, number>} Opcodes
*/ */
exports.Opcodes = { exports.Opcodes = {
@ -299,9 +304,8 @@ exports.Opcodes = {
HELLO: 10, // # Receive => sent immediately after connecting, contains heartbeat and server debug information 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 HEARTBEAT_ACK: 11, // # Sent => immediately following a client heartbeat that was received
GUILD_SYNC: 12, // # Receive => guild_sync but not used anymore 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 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_CONNECT: 15,
LOBBY_DISCONNECT: 16, LOBBY_DISCONNECT: 16,
LOBBY_VOICE_STATE_UPDATE: 17, // # Receive LOBBY_VOICE_STATE_UPDATE: 17, // # Receive
@ -311,6 +315,11 @@ exports.Opcodes = {
STREAM_PING: 21, // # Send STREAM_PING: 21, // # Send
STREAM_SET_PAUSED: 22, STREAM_SET_PAUSED: 22,
REQUEST_APPLICATION_COMMANDS: 24, // # Send => request application/bot cmds (user, message, and slash cmds) 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,
}; };
/** /**