@discordjs/core 3.0.0-djs-file-upload.1761302390-5ae769c9e → 3.0.0-pr-11006.1765450224-e636950b2

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
@@ -3141,8 +3141,7 @@ var API = class {
3141
3141
  };
3142
3142
 
3143
3143
  // src/client.ts
3144
- import { clearTimeout, setTimeout } from "timers";
3145
- import { calculateShardId } from "@discordjs/util";
3144
+ import { calculateShardId, GatewayRateLimitError } from "@discordjs/util";
3146
3145
  import { WebSocketShardEvents } from "@discordjs/ws";
3147
3146
  import { DiscordSnowflake } from "@sapphire/snowflake";
3148
3147
  import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
@@ -3189,6 +3188,18 @@ var Client = class extends AsyncEventEmitter {
3189
3188
  const nonce = options.nonce ?? DiscordSnowflake.generate().toString();
3190
3189
  const controller = new AbortController();
3191
3190
  let timer = createTimer(controller, timeout);
3191
+ const onRatelimit = /* @__PURE__ */ __name(({ data }) => {
3192
+ if (data.meta.nonce === nonce) {
3193
+ controller.abort(new GatewayRateLimitError(data, options));
3194
+ }
3195
+ }, "onRatelimit");
3196
+ const cleanup = /* @__PURE__ */ __name(() => {
3197
+ if (timer) {
3198
+ clearTimeout(timer);
3199
+ }
3200
+ this.off(GatewayDispatchEvents.RateLimited, onRatelimit);
3201
+ }, "cleanup");
3202
+ this.on(GatewayDispatchEvents.RateLimited, onRatelimit);
3192
3203
  await this.gateway.send(shardId, {
3193
3204
  op: GatewayOpcodes.RequestGuildMembers,
3194
3205
  // eslint-disable-next-line id-length
@@ -3218,13 +3229,14 @@ var Client = class extends AsyncEventEmitter {
3218
3229
  }
3219
3230
  } catch (error) {
3220
3231
  if (error instanceof Error && error.name === "AbortError") {
3232
+ if (error.cause instanceof GatewayRateLimitError) {
3233
+ throw error.cause;
3234
+ }
3221
3235
  throw new Error("Request timed out");
3222
3236
  }
3223
3237
  throw error;
3224
3238
  } finally {
3225
- if (timer) {
3226
- clearTimeout(timer);
3227
- }
3239
+ cleanup();
3228
3240
  }
3229
3241
  }
3230
3242
  /**
@@ -3386,7 +3398,8 @@ __name(withFiles, "withFiles");
3386
3398
 
3387
3399
  // src/index.ts
3388
3400
  export * from "discord-api-types/v10";
3389
- var version = "3.0.0-djs-file-upload.1761302390-5ae769c9e";
3401
+ import { GatewayRateLimitError as GatewayRateLimitError2 } from "@discordjs/util";
3402
+ var version = "3.0.0-pr-11006.1765450224-e636950b2";
3390
3403
  export {
3391
3404
  API,
3392
3405
  ApplicationCommandsAPI,
@@ -3394,6 +3407,7 @@ export {
3394
3407
  ChannelsAPI,
3395
3408
  Client,
3396
3409
  GatewayAPI,
3410
+ GatewayRateLimitError2 as GatewayRateLimitError,
3397
3411
  GuildsAPI,
3398
3412
  InteractionsAPI,
3399
3413
  InvitesAPI,