diff --git a/src/client/client.ts b/src/client/client.ts index 98ef161..985db04 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -5,6 +5,7 @@ import { type If, type WatcherPayload, type WatcherSendToShard, + hasIntent, lazyLoadPackage, } from '../common'; import { EventHandler } from '../events'; @@ -186,11 +187,13 @@ export class Client extends BaseClient { break; case 'READY': { const ids = packet.d.guilds.map(x => x.id); - this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids; + if (hasIntent(this.gateway.options.intents, 'Guilds')) { + this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids; + } this.botId = packet.d.user.id; this.applicationId = packet.d.application.id; this.me = Transformers.ClientUser(this, packet.d.user, packet.d.application) as never; - if (!this.__handleGuilds.length) { + if (!this.__handleGuilds?.length) { if ([...this.gateway.values()].every(shard => shard.data.session_id)) { await this.events?.runEvent('BOT_READY', this, this.me, -1); } diff --git a/src/client/workerclient.ts b/src/client/workerclient.ts index 17605fc..c068c19 100644 --- a/src/client/workerclient.ts +++ b/src/client/workerclient.ts @@ -1,7 +1,7 @@ import { type UUID, randomUUID } from 'node:crypto'; import { ApiHandler, Logger } from '..'; import { WorkerAdapter } from '../cache'; -import { type DeepPartial, LogLevels, type When, lazyLoadPackage } from '../common'; +import { type DeepPartial, LogLevels, type When, hasIntent, lazyLoadPackage } from '../common'; import { EventHandler } from '../events'; import type { GatewayDispatchPayload, GatewaySendPayload } from '../types'; import { Shard, type ShardManagerOptions, type WorkerData, properties } from '../websocket'; @@ -271,9 +271,11 @@ export class WorkerClient extends BaseClient { shardsConnected++; const ids = payload.d.guilds.map(x => x.id); - self.__handleGuildsResharding = self.__handleGuildsResharding?.concat(ids) ?? ids; + if (hasIntent(workerData.intents, 'Guilds')) { + self.__handleGuildsResharding = self.__handleGuildsResharding?.concat(ids) ?? ids; + } - if (shardsConnected === workerData.shards.length && !self.__handleGuildsResharding.length) { + if (shardsConnected === workerData.shards.length && !self.__handleGuildsResharding?.length) { delete self.__handleGuildsResharding; self.postMessage({ type: 'WORKER_READY_RESHARDING', @@ -532,7 +534,9 @@ export class WorkerClient extends BaseClient { case 'READY': { const ids = packet.d.guilds.map(x => x.id); - this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids; + if (hasIntent(this.workerData.intents, 'Guilds')) { + this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids; + } this.botId = packet.d.user.id; this.applicationId = packet.d.application.id; this.me = Transformers.ClientUser(this, packet.d.user, packet.d.application) as never; @@ -545,7 +549,7 @@ export class WorkerClient extends BaseClient { } as WorkerShardsConnected); await this.events?.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1); } - if (!this.__handleGuilds.length) { + if (!this.__handleGuilds!.length) { if ([...this.shards.values()].every(shard => shard.data.session_id)) { this.postMessage({ type: 'WORKER_READY', diff --git a/src/components/componentcontext.ts b/src/components/componentcontext.ts index a4e1693..10ed017 100644 --- a/src/components/componentcontext.ts +++ b/src/components/componentcontext.ts @@ -88,6 +88,13 @@ export class ComponentContext< return this.interaction.deferReply(ephemeral ? MessageFlags.Ephemeral : undefined); } + /** + * ACK an interaction and edit the original message later; the user does not see a loading state + */ + deferUpdate() { + return this.interaction.deferUpdate(); + } + /** * Edits the response of the interaction. * @param body - The updated body of the response.