From c6574fb92cb44538130ae0be2197cc1bf1c30b98 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Tue, 9 Nov 2021 17:24:22 +0000 Subject: [PATCH] cleanup caching on few events --- src/bot.ts | 15 ++++--- src/cache.ts | 1 + src/handlers/channels/CHANNEL_CREATE.ts | 1 - src/handlers/channels/CHANNEL_DELETE.ts | 42 ++++--------------- src/handlers/channels/CHANNEL_UPDATE.ts | 7 +--- src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts | 12 ++---- src/handlers/guilds/GUILD_BAN_ADD.ts | 5 +-- src/handlers/guilds/GUILD_CREATE.ts | 12 +----- src/handlers/guilds/GUILD_DELETE.ts | 14 +------ src/handlers/guilds/GUILD_LOADED_DD.ts | 6 +-- src/handlers/guilds/GUILD_UPDATE.ts | 6 +-- src/handlers/members/GUILD_MEMBERS_CHUNK.ts | 37 ++++++++-------- src/handlers/messages/MESSAGE_CREATE.ts | 5 +-- src/handlers/messages/MESSAGE_DELETE.ts | 6 +-- src/handlers/messages/MESSAGE_DELETE_BULK.ts | 27 +++--------- src/handlers/messages/MESSAGE_UPDATE.ts | 11 +---- src/handlers/misc/PRESENCE_UPDATE.ts | 9 +--- src/handlers/misc/USER_UPDATE.ts | 5 +-- .../members/fetchAndRetrieveMembers.ts | 7 ++++ src/types/members/request_guild_members.ts | 2 +- src/ws/identify.ts | 1 + 21 files changed, 67 insertions(+), 164 deletions(-) create mode 100644 src/helpers/members/fetchAndRetrieveMembers.ts diff --git a/src/bot.ts b/src/bot.ts index f538e0da1..b548fd107 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -111,6 +111,7 @@ import { transformThread } from "./transformers/thread.ts"; import { transformWebhook } from "./transformers/webhook.ts"; import { transformAuditlogEntry } from "./transformers/auditlogEntry.ts"; import { transformApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts"; +import { StatusUpdate } from "./types/gateway/status_update.ts"; type CacheOptions = | { @@ -911,6 +912,7 @@ export interface GatewayManager { $device: string; intents: number | (keyof typeof DiscordGatewayIntents)[]; shard: [number, number]; + presence?: Omit; /** The WSS URL that can be used for connecting to the gateway. */ urlWSS: string; @@ -1075,7 +1077,7 @@ export interface EventHandlers { ) => any; channelDelete: (bot: Bot, channel: DiscordenoChannel) => any; channelPinsUpdate: (bot: Bot, data: { guildId?: bigint; channelId: bigint; lastPinTimestamp?: number }) => any; - channelUpdate: (bot: Bot, channel: DiscordenoChannel, oldChannel: DiscordenoChannel) => any; + channelUpdate: (bot: Bot, channel: DiscordenoChannel) => any; stageInstanceCreate: ( bot: Bot, data: { @@ -1112,16 +1114,17 @@ export interface EventHandlers { // TODO: THREADS guildEmojisUpdate: ( bot: Bot, - guild: DiscordenoGuild, - emojis: Collection, - cachedEmojis: Collection + payload: { + guildId: bigint; + emojis: Collection; + } ) => any; guildBanAdd: (bot: Bot, user: DiscordenoUser, guildId: bigint) => any; guildBanRemove: (bot: Bot, user: DiscordenoUser, guildId: bigint) => any; guildLoaded: (bot: Bot, guild: DiscordenoGuild) => any; guildCreate: (bot: Bot, guild: DiscordenoGuild) => any; - guildDelete: (bot: Bot, id: bigint, guild?: DiscordenoGuild) => any; - guildUpdate: (bot: Bot, guild: DiscordenoGuild, cachedGuild?: DiscordenoGuild) => any; + guildDelete: (bot: Bot, id: bigint, shardId: number) => any; + guildUpdate: (bot: Bot, guild: DiscordenoGuild) => any; raw: (bot: Bot, data: GatewayPayload, shardId: number) => any; roleCreate: (bot: Bot, guild: DiscordenoGuild, role: DiscordenoRole) => any; roleDelete: (bot: Bot, guild: DiscordenoGuild, role: DiscordenoRole) => any; diff --git a/src/cache.ts b/src/cache.ts index 887292fc7..a801c086f 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -207,6 +207,7 @@ export type AsyncCacheHandler = { export type CacheExecutor = ( type: + | "GET_ALL_MEMBERS" | "FILTER_CATEGORY_CHILDREN_CHANNELS" | "DELETE_MESSAGES_FROM_CHANNEL" | "DELETE_ROLE_FROM_MEMBER" diff --git a/src/handlers/channels/CHANNEL_CREATE.ts b/src/handlers/channels/CHANNEL_CREATE.ts index 6cdf0c5d3..1e1e08a8e 100644 --- a/src/handlers/channels/CHANNEL_CREATE.ts +++ b/src/handlers/channels/CHANNEL_CREATE.ts @@ -6,7 +6,6 @@ import type { Bot } from "../../bot.ts"; export async function handleChannelCreate(bot: Bot, payload: DiscordGatewayPayload) { const channel = bot.transformers.channel(bot, { channel: payload.d as SnakeCasedPropertiesDeep }); - await bot.cache.channels.set(channel.id, channel); bot.events.channelCreate(bot, channel); } diff --git a/src/handlers/channels/CHANNEL_DELETE.ts b/src/handlers/channels/CHANNEL_DELETE.ts index d7be3c8d2..0c74582bf 100644 --- a/src/handlers/channels/CHANNEL_DELETE.ts +++ b/src/handlers/channels/CHANNEL_DELETE.ts @@ -1,45 +1,17 @@ import type { Channel } from "../../types/channels/channel.ts"; import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import type { Bot } from "../../bot.ts"; -import { DiscordChannelTypes } from "../../types/channels/channel_types.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleChannelDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; if (!payload.guild_id) return; - const [channel, guild] = await Promise.all([ - bot.cache.channels.get(bot.transformers.snowflake(payload.id)), - bot.cache.guilds.get(bot.transformers.snowflake(payload.guild_id)), - ]); - if (!channel) return; - - if (guild && [DiscordChannelTypes.GuildVoice, DiscordChannelTypes.GuildStageVoice].includes(channel.type)) { - guild.voiceStates?.forEach((vs, key) => { - if (vs.channelId !== channel.id) return; - - // Since this channel was deleted all voice states for this channel should be deleted - guild.voiceStates?.delete(key); - - bot.events.voiceChannelLeave(bot, vs, guild, channel); - }); - } - - if ( - [ - DiscordChannelTypes.GuildVoice, - DiscordChannelTypes.GuildText, - DiscordChannelTypes.DM, - DiscordChannelTypes.GroupDm, - DiscordChannelTypes.GuildNews, - ].includes(payload.type) - ) { - await bot.cache.execute("DELETE_MESSAGES_FROM_CHANNEL", { - channelId: bot.transformers.snowflake(payload.id), - }); - } - - await bot.cache.channels.delete(bot.transformers.snowflake(payload.id)); - - bot.events.channelDelete(bot, channel); + bot.events.channelDelete( + bot, + bot.transformers.channel(bot, { + channel: payload, + guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined, + }) + ); } diff --git a/src/handlers/channels/CHANNEL_UPDATE.ts b/src/handlers/channels/CHANNEL_UPDATE.ts index a17e03776..2e0449ab3 100644 --- a/src/handlers/channels/CHANNEL_UPDATE.ts +++ b/src/handlers/channels/CHANNEL_UPDATE.ts @@ -5,12 +5,7 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleChannelUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - - const cachedChannel = await bot.cache.channels.get(bot.transformers.snowflake(payload.id)); - if (!cachedChannel) return; - const channel = bot.transformers.channel(bot, { channel: payload }); - await bot.cache.channels.set(channel.id, channel); - bot.events.channelUpdate(bot, channel, cachedChannel); + bot.events.channelUpdate(bot, channel); } diff --git a/src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts b/src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts index 48640cf4f..d5917da1e 100644 --- a/src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts +++ b/src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts @@ -6,13 +6,9 @@ import { Collection } from "../../util/collection.ts"; export async function handleGuildEmojisUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - const guild = await bot.cache.guilds.get(bot.transformers.snowflake(payload.guild_id)); - if (!guild) return; - const cachedEmojis = guild.emojis; - guild.emojis = new Collection(payload.emojis.map((emoji) => [bot.transformers.snowflake(emoji.id!), emoji])); - - await bot.cache.guilds.set(guild.id, guild); - - bot.events.guildEmojisUpdate(bot, guild, guild.emojis, cachedEmojis); + bot.events.guildEmojisUpdate(bot, { + guildId: bot.transformers.snowflake(payload.guild_id), + emojis: new Collection(payload.emojis.map((emoji) => [bot.transformers.snowflake(emoji.id!), emoji])), + }); } diff --git a/src/handlers/guilds/GUILD_BAN_ADD.ts b/src/handlers/guilds/GUILD_BAN_ADD.ts index 0ebabfaac..7a040ab9d 100644 --- a/src/handlers/guilds/GUILD_BAN_ADD.ts +++ b/src/handlers/guilds/GUILD_BAN_ADD.ts @@ -5,12 +5,9 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleGuildBanAdd(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - // FIRST COMPLETE THE END USERS EVENT - await bot.events.guildBanAdd( + bot.events.guildBanAdd( bot, bot.transformers.user(bot, payload.user), bot.transformers.snowflake(payload.guild_id) ); - // THEN DELETE THE MEMBER - await bot.cache.members.delete(bot.transformers.snowflake(payload.user.id)); } diff --git a/src/handlers/guilds/GUILD_CREATE.ts b/src/handlers/guilds/GUILD_CREATE.ts index dacdd8529..3581f6e7a 100644 --- a/src/handlers/guilds/GUILD_CREATE.ts +++ b/src/handlers/guilds/GUILD_CREATE.ts @@ -3,15 +3,7 @@ import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload. import type { Guild } from "../../types/guilds/guild.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; -export async function handleGuildCreate( - bot: Bot, - data: DiscordGatewayPayload, - shardId: number -) { +export function handleGuildCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as SnakeCasedPropertiesDeep; - - const guild = bot.transformers.guild(bot, { guild: payload, shardId }); - await bot.cache.guilds.set(guild.id, guild); - - await bot.events.guildCreate(bot, guild); + bot.events.guildCreate(bot, bot.transformers.guild(bot, { guild: payload, shardId })); } diff --git a/src/handlers/guilds/GUILD_DELETE.ts b/src/handlers/guilds/GUILD_DELETE.ts index d1ac5573b..0e8de9e23 100644 --- a/src/handlers/guilds/GUILD_DELETE.ts +++ b/src/handlers/guilds/GUILD_DELETE.ts @@ -5,17 +5,5 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleGuildDelete(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as SnakeCasedPropertiesDeep; - - const id = bot.transformers.snowflake(payload.id); - const guild = await bot.cache.guilds.get(id); - await bot.events.guildDelete(bot, id, guild); - if (!guild) return; - - await bot.cache.guilds.delete(id); - - await Promise.all([ - bot.cache.execute("DELETE_MESSAGES_FROM_GUILD", { guildId: guild.id }), - bot.cache.execute("DELETE_CHANNELS_FROM_GUILD", { guildId: guild.id }), - bot.cache.execute("DELETE_GUILD_FROM_MEMBER", { guildId: guild.id }), - ]); + bot.events.guildDelete(bot, bot.transformers.snowflake(payload.id), shardId); } diff --git a/src/handlers/guilds/GUILD_LOADED_DD.ts b/src/handlers/guilds/GUILD_LOADED_DD.ts index 20a3fd542..d7b627bd6 100644 --- a/src/handlers/guilds/GUILD_LOADED_DD.ts +++ b/src/handlers/guilds/GUILD_LOADED_DD.ts @@ -3,7 +3,7 @@ import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload. import type { Guild } from "../../types/guilds/guild.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; -export async function handleGuildLoaded( +export function handleGuildLoaded( bot: Bot, data: DiscordGatewayPayload, shardId: number @@ -11,7 +11,5 @@ export async function handleGuildLoaded( const payload = data.d as SnakeCasedPropertiesDeep; const guild = bot.transformers.guild(bot, { guild: payload, shardId }); - await bot.cache.guilds.set(guild.id, guild); - - await bot.events.guildLoaded(bot, guild); + bot.events.guildLoaded(bot, guild); } diff --git a/src/handlers/guilds/GUILD_UPDATE.ts b/src/handlers/guilds/GUILD_UPDATE.ts index 62d2ecfad..168d348e4 100644 --- a/src/handlers/guilds/GUILD_UPDATE.ts +++ b/src/handlers/guilds/GUILD_UPDATE.ts @@ -6,9 +6,5 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleGuildUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as SnakeCasedPropertiesDeep; - const guild = bot.transformers.guild(bot, { guild: payload, shardId }); - const cached = await bot.cache.guilds.get(guild.id); - await bot.cache.guilds.set(guild.id, guild); - - bot.events.guildUpdate(bot, guild, cached); + bot.events.guildUpdate(bot, bot.transformers.guild(bot, { guild: payload, shardId })); } diff --git a/src/handlers/members/GUILD_MEMBERS_CHUNK.ts b/src/handlers/members/GUILD_MEMBERS_CHUNK.ts index d0f0f8149..8db74180b 100644 --- a/src/handlers/members/GUILD_MEMBERS_CHUNK.ts +++ b/src/handlers/members/GUILD_MEMBERS_CHUNK.ts @@ -1,4 +1,5 @@ import { Bot } from "../../bot.ts"; +import { statusTypes } from "../../transformers/presence.ts"; import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import type { GuildMembersChunk } from "../../types/members/guild_members_chunk.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; @@ -8,25 +9,25 @@ export async function handleGuildMembersChunk(bot: Bot, data: DiscordGatewayPayl const guildId = bot.transformers.snowflake(payload.guild_id); - await bot.cache.execute("GUILD_MEMBER_CHUNK", { + return { + guildId, members: payload.members.map((m) => bot.transformers.member(bot, m, guildId, bot.transformers.snowflake(m.user.id)) ), - users: payload.members.map((m) => bot.transformers.user(bot, m.user)), - }); - - if (!payload.nonce) return; - - // Check if its necessary to resolve the fetchmembers promise for this chunk or if more chunks will be coming - const resolve = bot.cache.fetchAllMembersProcessingRequests.get(payload.nonce); - if (!resolve) return; - - if (payload.chunk_index + 1 === payload.chunk_count) { - bot.cache.fetchAllMembersProcessingRequests.delete(payload.nonce); - return resolve("Finished chunking members"); - } + chunkIndex: payload.chunk_index, + chunkCount: payload.chunk_count, + notFound: payload.not_found?.map((id) => bot.transformers.snowflake(id)), + presences: payload.presences?.map((presence) => ({ + user: bot.transformers.user(bot, presence.user), + guildId, + status: statusTypes[presence.status], + activities: presence.activities.map((activity) => bot.transformers.activity(bot, activity)), + clientStatus: { + desktop: presence.client_status.desktop, + mobile: presence.client_status.mobile, + web: presence.client_status.web, + }, + })), + nonce: payload.nonce, + }; } - -// TODO: add a helper function that runs await fetch -// await fetchMembers(); -// const members = await bot.cache.members.findMany(guildId); diff --git a/src/handlers/messages/MESSAGE_CREATE.ts b/src/handlers/messages/MESSAGE_CREATE.ts index dc985d5ff..4769be7a5 100644 --- a/src/handlers/messages/MESSAGE_CREATE.ts +++ b/src/handlers/messages/MESSAGE_CREATE.ts @@ -6,8 +6,5 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleMessageCreate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - const message = bot.transformers.message(bot, payload); - await bot.cache.messages.set(message.id, message); - - bot.events.messageCreate(bot, message); + bot.events.messageCreate(bot, bot.transformers.message(bot, payload)); } diff --git a/src/handlers/messages/MESSAGE_DELETE.ts b/src/handlers/messages/MESSAGE_DELETE.ts index e4a1c061f..935feffbb 100644 --- a/src/handlers/messages/MESSAGE_DELETE.ts +++ b/src/handlers/messages/MESSAGE_DELETE.ts @@ -5,16 +5,12 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleMessageDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - const id = bot.transformers.snowflake(payload.id); bot.events.messageDelete(bot, { - id, + id: bot.transformers.snowflake(payload.id), channelId: bot.transformers.snowflake(payload.channel_id), guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined, }, - await bot.cache.messages.get(id) ); - - await bot.cache.messages.delete(id); } diff --git a/src/handlers/messages/MESSAGE_DELETE_BULK.ts b/src/handlers/messages/MESSAGE_DELETE_BULK.ts index 4d015a54e..90ae2319a 100644 --- a/src/handlers/messages/MESSAGE_DELETE_BULK.ts +++ b/src/handlers/messages/MESSAGE_DELETE_BULK.ts @@ -6,26 +6,9 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleMessageDeleteBulk(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - const ids = payload.ids.map((id) => bot.transformers.snowflake(id)); - const messages = (await bot.cache.execute("BULK_DELETE_MESSAGES", { messageIds: ids })) || []; - - ids.forEach((id) => { - // @ts-ignore let itoh fix cache typings hes the king of typigns and cache - const msg = messages.find((m) => m.id === id); - const message = msg - ? bot.utils.hasProperty(msg, "authorId") - ? msg - : bot.transformers.message(bot, msg) - : undefined; - - bot.events.messageDelete( - bot, - { - id, - channelId: bot.transformers.snowflake(payload.channel_id), - guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined, - }, - message - ); - }); + return { + ids: payload.ids.map((id) => bot.transformers.snowflake(id)), + channelId: bot.transformers.snowflake(payload.channel_id), + guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined, + }; } diff --git a/src/handlers/messages/MESSAGE_UPDATE.ts b/src/handlers/messages/MESSAGE_UPDATE.ts index 6662fd4ff..793935687 100644 --- a/src/handlers/messages/MESSAGE_UPDATE.ts +++ b/src/handlers/messages/MESSAGE_UPDATE.ts @@ -5,14 +5,5 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleMessageUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - if (!payload.edited_timestamp) return; - - const message = bot.transformers.message(bot, payload); - - // GET OLD CACHED MESSAGE IF ONE WAS CACHED - const oldMessage = await bot.cache.messages.get(message.id); - if (oldMessage?.content === message.content) return; - - await bot.cache.messages.set(message.id, message); - bot.events.messageUpdate(bot, message, oldMessage); + bot.events.messageUpdate(bot, bot.transformers.message(bot, payload)); } diff --git a/src/handlers/misc/PRESENCE_UPDATE.ts b/src/handlers/misc/PRESENCE_UPDATE.ts index e9b725ba5..6c90e6799 100644 --- a/src/handlers/misc/PRESENCE_UPDATE.ts +++ b/src/handlers/misc/PRESENCE_UPDATE.ts @@ -5,12 +5,5 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handlePresenceUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - - const id = bot.transformers.snowflake(payload.user.id); - - const oldPresence = await bot.cache.presences.get(id); - const presence = bot.transformers.presence(bot, payload); - await bot.cache.presences.set(id, presence); - - bot.events.presenceUpdate(bot, presence, oldPresence); + bot.events.presenceUpdate(bot, bot.transformers.presence(bot, payload)); } diff --git a/src/handlers/misc/USER_UPDATE.ts b/src/handlers/misc/USER_UPDATE.ts index ef252ac44..c194cc11e 100644 --- a/src/handlers/misc/USER_UPDATE.ts +++ b/src/handlers/misc/USER_UPDATE.ts @@ -5,8 +5,5 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleUserUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as SnakeCasedPropertiesDeep; - const user = bot.transformers.user(bot, payload); - await bot.cache.users.set(user.id, user); - - bot.events.botUpdate(bot, user); + bot.events.botUpdate(bot, bot.transformers.user(bot, payload)); } diff --git a/src/helpers/members/fetchAndRetrieveMembers.ts b/src/helpers/members/fetchAndRetrieveMembers.ts new file mode 100644 index 000000000..1b09f3c16 --- /dev/null +++ b/src/helpers/members/fetchAndRetrieveMembers.ts @@ -0,0 +1,7 @@ +import { Bot } from "../../bot.ts"; +import { RequestGuildMembers } from "../../types/members/request_guild_members.ts"; + +export async function fetchAndRetrieveMembers(bot: Bot, shardId: number, options: RequestGuildMembers) { + await bot.helpers.fetchMembers(options.guildId, shardId, options); + return await bot.cache.execute("GET_ALL_MEMBERS", { guildId: options.guildId }); +} diff --git a/src/types/members/request_guild_members.ts b/src/types/members/request_guild_members.ts index 6f7c57186..164b10a85 100644 --- a/src/types/members/request_guild_members.ts +++ b/src/types/members/request_guild_members.ts @@ -1,7 +1,7 @@ /** https://discord.com/developers/docs/topics/gateway#request-guild-members */ export interface RequestGuildMembers { /** id of the guild to get members for */ - guildId: string; + guildId: bigint; /** String that username starts with, or an empty string to return all members */ query?: string; /** Maximum number of members to send matching the query; a limit of 0 can be used with an empty string query to return all members */ diff --git a/src/ws/identify.ts b/src/ws/identify.ts index 457ab8939..93d7ebe62 100644 --- a/src/ws/identify.ts +++ b/src/ws/identify.ts @@ -54,6 +54,7 @@ export function identify(gateway: GatewayManager, shardId: number, maxShards: nu }, intents: gateway.intents, shard: [shardId, maxShards], + presence: gateway.presence }, }, true