@discordjs/core 3.0.0-dev.1762819348-37a38883d → 3.0.0-dev.1762862514-d3d6777ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3142,7 +3142,7 @@ var API = class {
3142
3142
 
3143
3143
  // src/client.ts
3144
3144
  import { clearTimeout, setTimeout } from "timers";
3145
- import { calculateShardId } from "@discordjs/util";
3145
+ import { calculateShardId, GatewayRateLimitError } from "@discordjs/util";
3146
3146
  import { WebSocketShardEvents } from "@discordjs/ws";
3147
3147
  import { DiscordSnowflake } from "@sapphire/snowflake";
3148
3148
  import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
@@ -3189,6 +3189,18 @@ var Client = class extends AsyncEventEmitter {
3189
3189
  const nonce = options.nonce ?? DiscordSnowflake.generate().toString();
3190
3190
  const controller = new AbortController();
3191
3191
  let timer = createTimer(controller, timeout);
3192
+ const onRatelimit = /* @__PURE__ */ __name(({ data }) => {
3193
+ if (data.meta.nonce === nonce) {
3194
+ controller.abort(new GatewayRateLimitError(data, options));
3195
+ }
3196
+ }, "onRatelimit");
3197
+ const cleanup = /* @__PURE__ */ __name(() => {
3198
+ if (timer) {
3199
+ clearTimeout(timer);
3200
+ }
3201
+ this.off(GatewayDispatchEvents.RateLimited, onRatelimit);
3202
+ }, "cleanup");
3203
+ this.on(GatewayDispatchEvents.RateLimited, onRatelimit);
3192
3204
  await this.gateway.send(shardId, {
3193
3205
  op: GatewayOpcodes.RequestGuildMembers,
3194
3206
  // eslint-disable-next-line id-length
@@ -3218,13 +3230,14 @@ var Client = class extends AsyncEventEmitter {
3218
3230
  }
3219
3231
  } catch (error) {
3220
3232
  if (error instanceof Error && error.name === "AbortError") {
3233
+ if (error.cause instanceof GatewayRateLimitError) {
3234
+ throw error.cause;
3235
+ }
3221
3236
  throw new Error("Request timed out");
3222
3237
  }
3223
3238
  throw error;
3224
3239
  } finally {
3225
- if (timer) {
3226
- clearTimeout(timer);
3227
- }
3240
+ cleanup();
3228
3241
  }
3229
3242
  }
3230
3243
  /**
@@ -3386,7 +3399,8 @@ __name(withFiles, "withFiles");
3386
3399
 
3387
3400
  // src/index.ts
3388
3401
  export * from "discord-api-types/v10";
3389
- var version = "3.0.0-dev.1762819348-37a38883d";
3402
+ import { GatewayRateLimitError as GatewayRateLimitError2 } from "@discordjs/util";
3403
+ var version = "3.0.0-dev.1762862514-d3d6777ef";
3390
3404
  export {
3391
3405
  API,
3392
3406
  ApplicationCommandsAPI,
@@ -3394,6 +3408,7 @@ export {
3394
3408
  ChannelsAPI,
3395
3409
  Client,
3396
3410
  GatewayAPI,
3411
+ GatewayRateLimitError2 as GatewayRateLimitError,
3397
3412
  GuildsAPI,
3398
3413
  InteractionsAPI,
3399
3414
  InvitesAPI,