@openclaw/discord 2026.7.2-beta.7 → 2026.8.1-beta.2

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.
Files changed (95) hide show
  1. package/dist/{account-inspect-SXiCBCgP.js → account-inspect-CqzrH14k.js} +48 -42
  2. package/dist/account-inspect-api.js +1 -1
  3. package/dist/action-runtime-api.js +1 -1
  4. package/dist/{active-turn-thread-route-MlKWp8RD.js → active-turn-thread-route-fmHl1HNd.js} +9 -11
  5. package/dist/{activities-api-DTKsuDxf.js → activities-api-DS7vpdtp.js} +4 -4
  6. package/dist/activities-api.js +1 -1
  7. package/dist/{allow-list-DzKrtfah.js → allow-list-DnxIlPP2.js} +2 -3
  8. package/dist/{api-DnrK9gML.js → api-DNVbJyEy.js} +7 -2
  9. package/dist/api.js +15 -15
  10. package/dist/{approval-handler.runtime-HymvFTYn.js → approval-handler.runtime-B6yEV79q.js} +5 -5
  11. package/dist/{approval-message-safety-DEyKVsAw.js → approval-message-safety-AcIxvrf3.js} +1 -1
  12. package/dist/{audit-CjsrabP8.js → audit-Db-rlntl.js} +4 -4
  13. package/dist/{channel-vKa-76xY.js → channel-CnnbJSt5.js} +46 -72
  14. package/dist/{channel-actions-uXFTJX3o.js → channel-actions-5s_hjYKd.js} +4 -4
  15. package/dist/{channel-actions.runtime-CIYU90sl.js → channel-actions.runtime-CLKrx6tr.js} +53 -36
  16. package/dist/channel-config-api.js +1 -1
  17. package/dist/channel-plugin-api.js +1 -1
  18. package/dist/{channel.setup-CmcwZ_qd.js → channel.setup-BFAO-V1P.js} +15 -53
  19. package/dist/{config-schema-WHRQcY19.js → config-schema-BgEskFAs.js} +9 -4
  20. package/dist/{directory-config-D_LojtCe.js → directory-config-BVX7Cflc.js} +1 -1
  21. package/dist/directory-contract-api.js +1 -1
  22. package/dist/{directory-live-Bw5Ephzv.js → directory-live-DGIGxpIo.js} +6 -3
  23. package/dist/{doctor-Bc4S1qyd.js → doctor-BzC-TLnB.js} +4 -4
  24. package/dist/{doctor-contract-CCFMIDk9.js → doctor-contract-DLa-BTiU.js} +2 -3
  25. package/dist/doctor-contract-api.js +147 -2
  26. package/dist/{handle-action.guild-admin-D6VRRW-C.js → handle-action.guild-admin-BNVTUISF.js} +4 -7
  27. package/dist/{inbound-event-delivery-CEPlt2uz.js → inbound-event-delivery-De2qxTrP.js} +4 -25
  28. package/dist/index.js +4 -2
  29. package/dist/{message-handler-CeiSulIw.js → message-handler-Unk_f10F.js} +41 -32
  30. package/dist/{message-handler.preflight-DibgQFf2.js → message-handler.preflight-C9zecxR9.js} +50 -26
  31. package/dist/{message-handler.process-Dnc_oz9y.js → message-handler.process-DWQ6UHHu.js} +130 -166
  32. package/dist/{message-utils-BgTwT_q7.js → message-utils-BSCPVgy0.js} +4 -4
  33. package/dist/{model-picker-preference-primitives-D25pnCOu.js → model-picker-preference-primitives-BHT1LkR_.js} +3 -3
  34. package/dist/{outbound-adapter-DtE-i2OJ.js → outbound-adapter-D9nRivT1.js} +91 -32
  35. package/dist/{outbound-components-C7GVyfPh.js → outbound-components-cTzwBJ60.js} +3 -3
  36. package/dist/{outbound-session-route-H-HoyH5U.js → outbound-session-route-DxLkrgKQ.js} +68 -95
  37. package/dist/{pluralkit-CD4B11JB.js → pluralkit-DdiJ9KMK.js} +1 -1
  38. package/dist/{preflight-audio-BjnQZ5yS.js → preflight-audio-DrnqFA8U.js} +22 -28
  39. package/dist/{probe-BeWKhjqX.js → probe-Bl-k5_Ku.js} +36 -12
  40. package/dist/probe.runtime-M9fREKvp.js +2 -0
  41. package/dist/{provider-DfQJX3z5.js → provider-DvSNb-2v.js} +969 -1248
  42. package/dist/{provider-session.runtime-Bo88k0pV.js → provider-session.runtime-BUEqD0rA.js} +3 -3
  43. package/dist/provider.runtime-C9PnJZbZ.js +2 -0
  44. package/dist/realtime-session.runtime-C7wen-aF.js +1340 -0
  45. package/dist/{resolve-allowlist-common-DHERApxi.js → resolve-allowlist-common-D04lpEzb.js} +2 -2
  46. package/dist/{resolve-channels-BjepAj8b.js → resolve-channels-Dm7jEeg6.js} +4 -4
  47. package/dist/{resolve-users-Bc28htgt.js → resolve-users-bktrCUUU.js} +3 -3
  48. package/dist/{chunk-DX4jpFQP.js → retry-CLpJcXXf.js} +291 -68
  49. package/dist/{runtime-_aRC6V2s.js → runtime-DGsSyDTS.js} +30 -25
  50. package/dist/{runtime-BmW_j_hl.js → runtime-DoHjckYm.js} +4 -6
  51. package/dist/runtime-api.actions.js +2 -2
  52. package/dist/runtime-api.js +22 -23
  53. package/dist/runtime-api.lookup.js +5 -5
  54. package/dist/runtime-api.monitor-CHxrFPnW.js +5 -0
  55. package/dist/runtime-api.monitor.js +5 -5
  56. package/dist/runtime-api.send.js +6 -6
  57. package/dist/runtime-api.threads.js +5 -6
  58. package/dist/sdk-runtime-QpY8PvCh.js +370 -0
  59. package/dist/{send-CdkZ6zeW.js → send-B7Q6Oc1I.js} +175 -86
  60. package/dist/{send.components-5uqwkjgE.js → send.components-iJyFXw9L.js} +24 -28
  61. package/dist/{send.outbound-D-80Ej-t.js → send.outbound-DS5tHwfR.js} +37 -24
  62. package/dist/{send.reactions-CtlmGd_o.js → send.reactions-BAn0iiVQ.js} +14 -21
  63. package/dist/{send.receipt-CuwRrpFz.js → send.receipt-IPI1p-SP.js} +19 -1
  64. package/dist/{send.shared-jpvAG_u6.js → send.shared-BmwFjW6T.js} +16 -85
  65. package/dist/{sender-identity-mG_zsdox.js → sender-identity-QtalnCYv.js} +1 -1
  66. package/dist/setup-entry.js +0 -5
  67. package/dist/setup-plugin-api.js +1 -1
  68. package/dist/{shared-CXF1tup1.js → shared-BIXIX6uJ.js} +16 -17
  69. package/dist/{subagent-hooks-Dxy7Fmnq.js → subagent-hooks-CTt5KCJr.js} +2 -2
  70. package/dist/subagent-hooks-api.js +2 -6
  71. package/dist/subagent-progress-DhaE_h8a.js +109 -0
  72. package/dist/{system-events-DdUqf91B.js → system-events-CTqDf6_s.js} +2 -2
  73. package/dist/{target-resolver-C3s_2m0t.js → target-resolver-maOKSqO0.js} +2 -2
  74. package/dist/targets-yUFTHoAx.js +3 -0
  75. package/dist/{thread-bindings-C-M-ly7P.js → thread-bindings-3L8p82GV.js} +5 -7
  76. package/dist/{thread-bindings.manager-DYvSlrva.js → thread-bindings.manager-DCIH6WDC.js} +257 -29
  77. package/dist/{thread-bindings.session-updates-DAIlp7Px.js → thread-bindings.session-updates-bJ2KQFY6.js} +1 -1
  78. package/dist/{thread-bindings.state-Cgi5uRn-.js → thread-bindings.state-aeV8HNgV.js} +2 -15
  79. package/dist/{transcripts-source-DIKGsTGT.js → transcripts-source-CfFMexGt.js} +1 -1
  80. package/dist/transcripts-source-api.js +1 -1
  81. package/dist/{typing--Mzo2kM7.js → typing-CS-nNVoe.js} +1 -1
  82. package/dist/voice-runtime-BEdqNcST.js +2459 -0
  83. package/openclaw.plugin.json +203 -19
  84. package/package.json +15 -9
  85. package/skills/discord/SKILL.md +22 -115
  86. package/dist/legacy-state-migrations-api.js +0 -138
  87. package/dist/manager.runtime-Bjav3pfC.js +0 -3655
  88. package/dist/preflight-audio.runtime-CoCXMM8r.js +0 -7
  89. package/dist/probe.runtime-DqFGFMbZ.js +0 -2
  90. package/dist/provider.runtime-Cy7XZmyh.js +0 -2
  91. package/dist/runtime-api.monitor-CCRubd3-.js +0 -5
  92. package/dist/session-binding-contract-api.js +0 -2
  93. package/dist/subagent-progress-DI3sYLLo.js +0 -664
  94. package/dist/targets-Dv_RN7vT.js +0 -3
  95. package/dist/thread-bindings.discord-api-BoDNqamb.js +0 -246
@@ -1,16 +1,18 @@
1
1
  import { t as parseDiscordRetryAfterBodySeconds } from "./retry-after-DdLPmPoa.js";
2
2
  import "node:module";
3
+ import { redactIdentifier, redactSensitiveFieldValue } from "openclaw/plugin-sdk/logging-core";
3
4
  import { ApplicationCommandOptionType, ApplicationCommandType, ButtonStyle, ComponentType, GatewayDispatchEvents, InteractionContextType, InteractionResponseType, InteractionType, MessageFlags, Routes, TextInputStyle } from "discord-api-types/v10";
4
5
  import { createHash } from "node:crypto";
5
- import { asDateTimestampMs, clampTimerTimeoutMs, parseFiniteNumber, parseStrictNonNegativeInteger, resolveExpiresAtMsFromDurationMs, resolveIntegerOption, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
6
+ import { asDateTimestampMs, clampTimerTimeoutMs, parseStrictNonNegativeInteger, resolveExpiresAtMsFromDurationMs, resolveIntegerOption, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
6
7
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
7
8
  import { Type } from "typebox";
8
9
  import { Check } from "typebox/value";
9
10
  import { inspect } from "node:util";
10
11
  import { gunzipSync } from "node:zlib";
11
12
  import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
12
- import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
13
- import { parseRetryAfterHeaderSeconds } from "openclaw/plugin-sdk/retry-runtime";
13
+ import { collectErrorGraphCandidates, extractErrorCode, formatErrorMessage, readErrorName } from "openclaw/plugin-sdk/error-runtime";
14
+ import { classifyTransientNetworkErrorCode, createChannelApiRetryRunner, parseRetryAfterHeaderSeconds, resolveRetryConfig, retryAsync } from "openclaw/plugin-sdk/retry-runtime";
15
+ import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
14
16
  import { buildMessagingTarget, parseMentionPrefixOrAtUserTarget, requireTargetKind } from "openclaw/plugin-sdk/channel-targets";
15
17
  import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
16
18
  import { chunkMarkdownTextWithMode } from "openclaw/plugin-sdk/reply-chunking";
@@ -402,6 +404,11 @@ function stableCommandSetHash(commands) {
402
404
  return createHash("sha256").update(JSON.stringify(stable)).digest("hex");
403
405
  }
404
406
  //#endregion
407
+ //#region extensions/discord/src/internal/undefined-fields.ts
408
+ function stripUndefinedFields(value) {
409
+ return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
410
+ }
411
+ //#endregion
405
412
  //#region extensions/discord/src/internal/components.base.ts
406
413
  function parseCustomId(id) {
407
414
  const [rawKeyValue, ...parts] = id.split(";");
@@ -423,9 +430,6 @@ function parseCustomId(id) {
423
430
  data
424
431
  };
425
432
  }
426
- function clean$3(value) {
427
- return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
428
- }
429
433
  function colorToNumber(value) {
430
434
  if (typeof value === "number") return Number.isInteger(value) && value >= 0 && value <= 16777215 ? value : void 0;
431
435
  if (typeof value === "string" && /^#?[0-9a-f]{6}$/i.test(value)) return Number.parseInt(value.replace(/^#/, ""), 16);
@@ -458,7 +462,7 @@ var BaseButton = class extends BaseMessageInteractiveComponent {
458
462
  };
459
463
  var Button = class extends BaseButton {
460
464
  serialize() {
461
- return clean$3({
465
+ return stripUndefinedFields({
462
466
  type: this.type,
463
467
  style: this.style,
464
468
  custom_id: this.customId,
@@ -478,7 +482,7 @@ var LinkButton = class extends BaseButton {
478
482
  throw new Error("Link buttons do not run handlers");
479
483
  }
480
484
  serialize() {
481
- return clean$3({
485
+ return stripUndefinedFields({
482
486
  type: this.type,
483
487
  style: this.style,
484
488
  label: this.label,
@@ -494,7 +498,7 @@ var AnySelectMenu = class extends BaseMessageInteractiveComponent {
494
498
  this.disabled = false;
495
499
  }
496
500
  serialize() {
497
- return clean$3({
501
+ return stripUndefinedFields({
498
502
  ...this.serializeOptions(),
499
503
  custom_id: this.customId,
500
504
  placeholder: this.placeholder,
@@ -591,7 +595,7 @@ var TextDisplay = class extends BaseComponent {
591
595
  this.isV2 = true;
592
596
  }
593
597
  serialize() {
594
- return clean$3({
598
+ return stripUndefinedFields({
595
599
  type: this.type,
596
600
  content: this.content
597
601
  });
@@ -608,7 +612,7 @@ var Separator = class extends BaseComponent {
608
612
  this.divider = options?.divider ?? this.divider;
609
613
  }
610
614
  serialize() {
611
- return clean$3({
615
+ return stripUndefinedFields({
612
616
  type: this.type,
613
617
  divider: this.divider,
614
618
  spacing: this.spacing === "large" ? 2 : this.spacing === "small" ? 1 : this.spacing
@@ -623,7 +627,7 @@ var Thumbnail = class extends BaseComponent {
623
627
  this.isV2 = true;
624
628
  }
625
629
  serialize() {
626
- return clean$3({
630
+ return stripUndefinedFields({
627
631
  type: this.type,
628
632
  media: this.url ? { url: this.url } : void 0
629
633
  });
@@ -638,7 +642,7 @@ var Section = class extends BaseComponent {
638
642
  this.isV2 = true;
639
643
  }
640
644
  serialize() {
641
- return clean$3({
645
+ return stripUndefinedFields({
642
646
  type: this.type,
643
647
  components: this.components.map((entry) => entry.serialize()),
644
648
  accessory: this.accessory?.serialize()
@@ -672,7 +676,7 @@ var File = class extends BaseComponent {
672
676
  this.isV2 = true;
673
677
  }
674
678
  serialize() {
675
- return clean$3({
679
+ return stripUndefinedFields({
676
680
  type: this.type,
677
681
  file: this.file ? { url: this.file } : void 0,
678
682
  spoiler: this.spoiler || void 0
@@ -690,7 +694,7 @@ var Container = class extends BaseComponent {
690
694
  this.spoiler = options?.spoiler ?? false;
691
695
  }
692
696
  serialize() {
693
- return clean$3({
697
+ return stripUndefinedFields({
694
698
  type: this.type,
695
699
  components: this.components.map((entry) => entry.serialize()),
696
700
  accent_color: colorToNumber(this.accentColor),
@@ -708,7 +712,7 @@ var TextInput = class extends BaseModalComponent {
708
712
  this.style = TextInputStyle.Short;
709
713
  }
710
714
  serialize() {
711
- return clean$3({
715
+ return stripUndefinedFields({
712
716
  type: this.type,
713
717
  custom_id: this.customId,
714
718
  style: this.style,
@@ -727,7 +731,7 @@ var CheckboxGroup = class extends BaseModalComponent {
727
731
  this.options = [];
728
732
  }
729
733
  serialize() {
730
- return clean$3({
734
+ return stripUndefinedFields({
731
735
  type: this.type,
732
736
  custom_id: this.customId,
733
737
  options: this.options,
@@ -744,7 +748,7 @@ var RadioGroup = class extends BaseModalComponent {
744
748
  this.options = [];
745
749
  }
746
750
  serialize() {
747
- return clean$3({
751
+ return stripUndefinedFields({
748
752
  type: this.type,
749
753
  custom_id: this.customId,
750
754
  options: this.options,
@@ -762,7 +766,7 @@ var Label = class extends BaseModalComponent {
762
766
  this.customId = "";
763
767
  }
764
768
  serialize() {
765
- return clean$3({
769
+ return stripUndefinedFields({
766
770
  type: this.type,
767
771
  label: this.label,
768
772
  description: this.description,
@@ -785,15 +789,12 @@ var Modal = class {
785
789
  };
786
790
  //#endregion
787
791
  //#region extensions/discord/src/internal/embeds.ts
788
- function clean$2(value) {
789
- return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
790
- }
791
792
  var Embed = class {
792
793
  constructor(embed) {
793
794
  Object.assign(this, embed);
794
795
  }
795
796
  serialize() {
796
- return clean$2({
797
+ return stripUndefinedFields({
797
798
  title: this.title,
798
799
  description: this.description,
799
800
  url: this.url,
@@ -809,9 +810,6 @@ var Embed = class {
809
810
  };
810
811
  //#endregion
811
812
  //#region extensions/discord/src/internal/payload.ts
812
- function clean$1(value) {
813
- return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
814
- }
815
813
  function serializeAnyComponent(component) {
816
814
  return component.serialize();
817
815
  }
@@ -827,7 +825,7 @@ function normalizePayloadFlags(payload) {
827
825
  function serializePayload(payload) {
828
826
  if (typeof payload === "string") return { content: payload };
829
827
  const flags = normalizePayloadFlags(payload);
830
- return clean$1({
828
+ return stripUndefinedFields({
831
829
  content: payload.content,
832
830
  embeds: payload.embeds?.map((entry) => "serialize" in entry ? entry.serialize() : entry),
833
831
  components: payload.components?.map((entry) => serializeAnyComponent(entry)),
@@ -881,7 +879,7 @@ var ComponentRegistry = class {
881
879
  clearTimeout(existing.timer);
882
880
  existing.resolve({
883
881
  success: false,
884
- message,
882
+ message: existing.message,
885
883
  reason: "timed out"
886
884
  });
887
885
  }
@@ -1169,11 +1167,15 @@ var DiscordEntityCache = class {
1169
1167
  const raw = data && typeof data === "object" ? data : {};
1170
1168
  const channelUpdate = GatewayDispatchEvents.ChannelUpdate;
1171
1169
  const channelDelete = GatewayDispatchEvents.ChannelDelete;
1170
+ const threadUpdate = GatewayDispatchEvents.ThreadUpdate;
1171
+ const threadDelete = GatewayDispatchEvents.ThreadDelete;
1172
1172
  const guildUpdate = GatewayDispatchEvents.GuildUpdate;
1173
+ const guildMemberAdd = GatewayDispatchEvents.GuildMemberAdd;
1174
+ const guildMemberRemove = GatewayDispatchEvents.GuildMemberRemove;
1173
1175
  const guildMemberUpdate = GatewayDispatchEvents.GuildMemberUpdate;
1174
- if (type === channelUpdate || type === channelDelete) this.deleteId("channel", raw.id);
1176
+ if (type === channelUpdate || type === channelDelete || type === threadUpdate || type === threadDelete) this.deleteId("channel", raw.id);
1175
1177
  if (type === guildUpdate) this.deleteId("guild", raw.id);
1176
- if (type === guildMemberUpdate) {
1178
+ if (type === guildMemberAdd || type === guildMemberRemove || type === guildMemberUpdate) {
1177
1179
  const guildId = raw.guild_id;
1178
1180
  const user = raw.user && typeof raw.user === "object" ? raw.user : {};
1179
1181
  if (typeof guildId === "string" && typeof user.id === "string") {
@@ -1360,9 +1362,6 @@ function isListenerTimeoutError(error) {
1360
1362
  }
1361
1363
  //#endregion
1362
1364
  //#region extensions/discord/src/internal/commands.ts
1363
- function clean(value) {
1364
- return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
1365
- }
1366
1365
  function resolveConditionalCommandOption(value, interaction) {
1367
1366
  return typeof value === "function" ? value(interaction) : value;
1368
1367
  }
@@ -1402,7 +1401,7 @@ var BaseCommand = class {
1402
1401
  ];
1403
1402
  }
1404
1403
  serialize() {
1405
- return clean({
1404
+ return stripUndefinedFields({
1406
1405
  name: this.name,
1407
1406
  name_localizations: this.nameLocalizations,
1408
1407
  description: this.type === ApplicationCommandType.ChatInput ? this.description ?? "" : void 0,
@@ -1451,7 +1450,7 @@ var CommandWithSubcommands = class extends BaseCommand {
1451
1450
  return await subcommand.run(interaction);
1452
1451
  }
1453
1452
  serializeOptions() {
1454
- return this.subcommands.map((command) => clean({
1453
+ return this.subcommands.map((command) => stripUndefinedFields({
1455
1454
  name: command.name,
1456
1455
  name_localizations: command.nameLocalizations,
1457
1456
  description: command.description ?? "",
@@ -1660,6 +1659,7 @@ var BaseInteraction = class {
1660
1659
  this.rawData = rawData;
1661
1660
  this.message = null;
1662
1661
  this.response = new InteractionResponseController();
1662
+ this.pendingResponse = Promise.resolve();
1663
1663
  this.id = rawData.id;
1664
1664
  this.token = rawData.token;
1665
1665
  this.user = readInteractionUser(rawData, client);
@@ -1676,18 +1676,30 @@ var BaseInteraction = class {
1676
1676
  set responseState(nextState) {
1677
1677
  this.response.state = nextState;
1678
1678
  }
1679
- async callback(type, data) {
1680
- this.response.recordCallback(type);
1681
- return await createInteractionCallback(this.client.rest, this.id, this.token, data === void 0 ? { type } : {
1679
+ enqueueResponse(operation) {
1680
+ const result = this.pendingResponse.then(operation);
1681
+ this.pendingResponse = result.then(() => void 0, () => void 0);
1682
+ return result;
1683
+ }
1684
+ async performCallback(type, data) {
1685
+ if (this.response.acknowledged) throw new Error("Discord interaction has already been acknowledged.");
1686
+ const result = await createInteractionCallback(this.client.rest, this.id, this.token, data === void 0 ? { type } : {
1682
1687
  type,
1683
1688
  data
1684
1689
  });
1690
+ this.response.recordCallback(type);
1691
+ return result;
1692
+ }
1693
+ async callback(type, data) {
1694
+ return await this.enqueueResponse(() => this.performCallback(type, data));
1685
1695
  }
1686
1696
  async reply(payload) {
1687
- const action = this.response.nextReplyAction();
1688
- if (action === "edit") return await this.editReply(payload);
1689
- if (action === "follow-up") return await this.followUp(payload);
1690
- return await this.callback(InteractionResponseType.ChannelMessageWithSource, serializePayload(payload));
1697
+ return await this.enqueueResponse(async () => {
1698
+ const action = this.response.nextReplyAction();
1699
+ if (action === "edit") return await this.performReplyEdit(payload);
1700
+ if (action === "follow-up") return await this.performFollowUp(payload);
1701
+ return await this.performCallback(InteractionResponseType.ChannelMessageWithSource, serializePayload(payload));
1702
+ });
1691
1703
  }
1692
1704
  async defer(options) {
1693
1705
  return await this.callback(InteractionResponseType.DeferredChannelMessageWithSource, options?.ephemeral ? { flags: 64 } : void 0);
@@ -1696,6 +1708,9 @@ var BaseInteraction = class {
1696
1708
  return await this.defer();
1697
1709
  }
1698
1710
  async editReply(payload) {
1711
+ return await this.enqueueResponse(() => this.performReplyEdit(payload));
1712
+ }
1713
+ async performReplyEdit(payload) {
1699
1714
  const body = serializePayload(payload);
1700
1715
  const query = needsComponentsV2Query(body) ? { with_components: true } : void 0;
1701
1716
  const result = query ? await editWebhookMessage(this.client.rest, this.client.options.clientId, this.token, "@original", { body }, query) : await editWebhookMessage(this.client.rest, this.client.options.clientId, this.token, "@original", { body });
@@ -1703,12 +1718,14 @@ var BaseInteraction = class {
1703
1718
  return result;
1704
1719
  }
1705
1720
  async deleteReply() {
1706
- const result = await deleteWebhookMessage(this.client.rest, this.client.options.clientId, this.token, "@original");
1707
- this.response.recordReplyDelete();
1708
- return result;
1721
+ return await this.enqueueResponse(async () => {
1722
+ const result = await deleteWebhookMessage(this.client.rest, this.client.options.clientId, this.token, "@original");
1723
+ this.response.recordReplyDelete();
1724
+ return result;
1725
+ });
1709
1726
  }
1710
1727
  async fetchReply() {
1711
- return await getWebhookMessage(this.client.rest, this.client.options.clientId, this.token, "@original");
1728
+ return await this.enqueueResponse(() => getWebhookMessage(this.client.rest, this.client.options.clientId, this.token, "@original"));
1712
1729
  }
1713
1730
  async replyAndWaitForComponent(payload, timeoutMs = 3e5) {
1714
1731
  const result = await this.reply(payload);
@@ -1718,6 +1735,9 @@ var BaseInteraction = class {
1718
1735
  return await this.client.componentHandler.waitForMessageComponent(message, timeoutMs);
1719
1736
  }
1720
1737
  async followUp(payload) {
1738
+ return await this.enqueueResponse(() => this.performFollowUp(payload));
1739
+ }
1740
+ async performFollowUp(payload) {
1721
1741
  const body = serializePayload(payload);
1722
1742
  return await createWebhookMessage(this.client.rest, this.client.options.clientId, this.token, { body }, needsComponentsV2Query(body) ? { with_components: true } : void 0);
1723
1743
  }
@@ -1933,6 +1953,90 @@ function serializeRequestBody(data, headers) {
1933
1953
  //#endregion
1934
1954
  //#region extensions/discord/src/internal/rest-errors.ts
1935
1955
  const DISCORD_UNKNOWN_VOICE_STATE = 10065;
1956
+ const DISCORD_ERROR_BODY_MAX_DEPTH = 64;
1957
+ const DISCORD_ERROR_BODY_MAX_NODES = 1e4;
1958
+ const DISCORD_ERROR_BODY_MAX_DEPTH_MARKER = "[Discord error body redacted: maximum depth exceeded]";
1959
+ const DISCORD_ERROR_BODY_MAX_NODES_MARKER = "[Discord error body redacted: node limit exceeded]";
1960
+ const DISCORD_ERROR_BODY_PRIORITY_KEYS = /* @__PURE__ */ new Set([
1961
+ "message",
1962
+ "code",
1963
+ "retry_after",
1964
+ "global"
1965
+ ]);
1966
+ const DISCORD_RATE_LIMIT_SCOPES = /* @__PURE__ */ new Set([
1967
+ "user",
1968
+ "global",
1969
+ "shared"
1970
+ ]);
1971
+ function isSensitiveDiscordErrorKey(key) {
1972
+ return redactSensitiveFieldValue(key, "") !== "";
1973
+ }
1974
+ function reserveRedactedKey(key, usedKeys, collisionCounts) {
1975
+ let count = (collisionCounts.get(key) ?? 0) + 1;
1976
+ let candidate = count === 1 ? key : `${key} [${count}]`;
1977
+ while (usedKeys.has(candidate)) {
1978
+ count += 1;
1979
+ candidate = `${key} [${count}]`;
1980
+ }
1981
+ collisionCounts.set(key, count);
1982
+ usedKeys.add(candidate);
1983
+ return candidate;
1984
+ }
1985
+ function redactDiscordErrorBody(body, fieldKey = "", sensitiveAncestorKey, state = {
1986
+ seen: /* @__PURE__ */ new WeakSet(),
1987
+ remainingNodes: DISCORD_ERROR_BODY_MAX_NODES
1988
+ }, depth = 0) {
1989
+ if (state.remainingNodes <= 0) return DISCORD_ERROR_BODY_MAX_NODES_MARKER;
1990
+ state.remainingNodes -= 1;
1991
+ if (typeof body === "string") return redactSensitiveFieldValue(sensitiveAncestorKey ?? fieldKey, body);
1992
+ if (sensitiveAncestorKey && (typeof body === "number" || typeof body === "boolean" || typeof body === "bigint")) return redactSensitiveFieldValue(sensitiveAncestorKey, String(body));
1993
+ if (!body || typeof body !== "object") return body;
1994
+ if (depth >= DISCORD_ERROR_BODY_MAX_DEPTH) return DISCORD_ERROR_BODY_MAX_DEPTH_MARKER;
1995
+ if (state.seen.has(body)) return "[Circular]";
1996
+ state.seen.add(body);
1997
+ let redacted;
1998
+ if (Array.isArray(body)) {
1999
+ const items = [];
2000
+ for (const entry of body) {
2001
+ if (state.remainingNodes <= 0) {
2002
+ items.push(DISCORD_ERROR_BODY_MAX_NODES_MARKER);
2003
+ break;
2004
+ }
2005
+ items.push(redactDiscordErrorBody(entry, fieldKey, sensitiveAncestorKey, state, depth + 1));
2006
+ }
2007
+ redacted = items;
2008
+ } else {
2009
+ const usedKeys = /* @__PURE__ */ new Set();
2010
+ const collisionCounts = /* @__PURE__ */ new Map();
2011
+ const entries = [];
2012
+ const appendEntry = (nestedKey) => {
2013
+ if (state.remainingNodes <= 0) return false;
2014
+ const outputKey = reserveRedactedKey(redactSensitiveFieldValue(sensitiveAncestorKey ?? "", nestedKey), usedKeys, collisionCounts);
2015
+ const nestedSensitiveKey = isSensitiveDiscordErrorKey(nestedKey) ? nestedKey : sensitiveAncestorKey;
2016
+ entries.push([outputKey, redactDiscordErrorBody(body[nestedKey], nestedKey, nestedSensitiveKey, state, depth + 1)]);
2017
+ return true;
2018
+ };
2019
+ let truncated = false;
2020
+ for (const priorityKey of DISCORD_ERROR_BODY_PRIORITY_KEYS) if (Object.hasOwn(body, priorityKey) && !appendEntry(priorityKey)) {
2021
+ truncated = true;
2022
+ break;
2023
+ }
2024
+ if (!truncated) for (const nestedKey in body) {
2025
+ if (!Object.hasOwn(body, nestedKey) || DISCORD_ERROR_BODY_PRIORITY_KEYS.has(nestedKey)) continue;
2026
+ if (!appendEntry(nestedKey)) {
2027
+ truncated = true;
2028
+ break;
2029
+ }
2030
+ }
2031
+ if (truncated) {
2032
+ const markerKey = reserveRedactedKey(DISCORD_ERROR_BODY_MAX_NODES_MARKER, usedKeys, collisionCounts);
2033
+ entries.push([markerKey, DISCORD_ERROR_BODY_MAX_NODES_MARKER]);
2034
+ }
2035
+ redacted = Object.fromEntries(entries);
2036
+ }
2037
+ state.seen.delete(body);
2038
+ return redacted;
2039
+ }
1936
2040
  function readDiscordCode(body) {
1937
2041
  return parseStrictNonNegativeInteger(body && typeof body === "object" && "code" in body ? body.code : void 0);
1938
2042
  }
@@ -1946,14 +2050,24 @@ function isUnknownDiscordVoiceStateError(err) {
1946
2050
  function readRetryAfter(body, response, fallbackSeconds = 0) {
1947
2051
  return parseDiscordRetryAfterBodySeconds(body && typeof body === "object" && "retry_after" in body ? body.retry_after : void 0) ?? parseRetryAfterHeaderSeconds(response.headers.get("Retry-After")) ?? fallbackSeconds;
1948
2052
  }
2053
+ function readDiscordRateLimitBucket(response) {
2054
+ const value = response.headers.get("X-RateLimit-Bucket")?.trim();
2055
+ return value ? redactIdentifier(value, { len: 32 }) : null;
2056
+ }
2057
+ function readDiscordRateLimitScope(response) {
2058
+ const value = response.headers.get("X-RateLimit-Scope");
2059
+ return value && DISCORD_RATE_LIMIT_SCOPES.has(value) ? value : null;
2060
+ }
1949
2061
  var DiscordError = class extends Error {
1950
2062
  constructor(response, body) {
1951
- super(readDiscordMessage(body, `Discord API request failed (${response.status})`));
2063
+ const redactedMessage = redactSensitiveFieldValue("message", readDiscordMessage(body, `Discord API request failed (${response.status})`));
2064
+ const redactedBody = redactDiscordErrorBody(body);
2065
+ super(redactedMessage);
1952
2066
  this.name = "DiscordError";
1953
2067
  this.status = response.status;
1954
2068
  this.statusCode = response.status;
1955
- this.rawBody = body;
1956
- this.rawError = body;
2069
+ this.rawBody = redactedBody;
2070
+ this.rawError = redactedBody;
1957
2071
  this.discordCode = readDiscordCode(body);
1958
2072
  }
1959
2073
  };
@@ -1962,21 +2076,30 @@ var RateLimitError = class extends DiscordError {
1962
2076
  super(response, body);
1963
2077
  this.name = "RateLimitError";
1964
2078
  this.retryAfter = readRetryAfter(body, response, 1);
1965
- this.scope = body.global ? "global" : response.headers.get("X-RateLimit-Scope");
1966
- this.bucket = response.headers.get("X-RateLimit-Bucket");
2079
+ this.scope = body.global ? "global" : readDiscordRateLimitScope(response);
2080
+ this.bucket = readDiscordRateLimitBucket(response);
1967
2081
  }
1968
2082
  };
1969
2083
  //#endregion
1970
2084
  //#region extensions/discord/src/internal/rest-routes.ts
1971
2085
  const RATE_LIMIT_HEADER_NUMBER_RE = /^\d+(?:\.\d+)?$/;
2086
+ const DISCORD_ROUTE_IDENTIFIER_HASH_LENGTH = 32;
2087
+ function redactWebhookTokenInPath(path) {
2088
+ const hasLeadingSlash = path.startsWith("/");
2089
+ const segments = path.replace(/^\/+/, "").split("/");
2090
+ if (segments[0] !== "webhooks" || !segments[1] || !segments[2]) return path;
2091
+ segments[2] = redactIdentifier(segments[2], { len: DISCORD_ROUTE_IDENTIFIER_HASH_LENGTH });
2092
+ return `${hasLeadingSlash ? "/" : ""}${segments.join("/")}`;
2093
+ }
1972
2094
  function createRouteKey(method, path) {
1973
- return `${method.toUpperCase()} ${path.split("?")[0] ?? path}`;
2095
+ const pathname = path.split("?")[0] ?? path;
2096
+ return `${method.toUpperCase()} ${redactWebhookTokenInPath(pathname)}`;
1974
2097
  }
1975
2098
  function readTopLevelRouteKey(path) {
1976
2099
  const [pathname = path] = path.split("?");
1977
2100
  const [first, id, token] = pathname.replace(/^\/+/, "").split("/");
1978
2101
  if (!first || !id) return pathname;
1979
- if (first === "channels" || first === "guilds" || first === "webhooks") return first === "webhooks" && token ? `${first}/${id}/${token}` : `${first}/${id}`;
2102
+ if (first === "channels" || first === "guilds" || first === "webhooks") return first === "webhooks" && token ? `${first}/${id}/${redactIdentifier(token, { len: DISCORD_ROUTE_IDENTIFIER_HASH_LENGTH })}` : `${first}/${id}`;
1980
2103
  return first;
1981
2104
  }
1982
2105
  function createBucketKey(bucket, path) {
@@ -2198,7 +2321,7 @@ var RestScheduler = class {
2198
2321
  return target;
2199
2322
  }
2200
2323
  updateRateLimitState(routeKey, path, response, parsed) {
2201
- const bucketHeader = response.headers.get("X-RateLimit-Bucket");
2324
+ const bucketHeader = readDiscordRateLimitBucket(response);
2202
2325
  const bucket = bucketHeader ? this.bindRouteToBucket(routeKey, createBucketKey(bucketHeader, path)) : this.getBucket(this.routeBuckets.get(routeKey) ?? routeKey);
2203
2326
  bucket.bucket = bucketHeader ?? bucket.bucket;
2204
2327
  const limit = readHeaderNumber(response.headers, "X-RateLimit-Limit");
@@ -2227,7 +2350,7 @@ var RestScheduler = class {
2227
2350
  status: response.status
2228
2351
  });
2229
2352
  this.pruneInvalidRequests(now);
2230
- const bucketHeader = response.headers.get("X-RateLimit-Bucket");
2353
+ const bucketHeader = readDiscordRateLimitBucket(response);
2231
2354
  const bucketKey = bucketHeader ? createBucketKey(bucketHeader, path) : this.routeBuckets.get(routeKey) ?? routeKey;
2232
2355
  const bucket = this.buckets.get(bucketKey);
2233
2356
  if (bucket) bucket.invalidRequests += 1;
@@ -2440,9 +2563,9 @@ var RequestClient = class {
2440
2563
  this.options = normalizeRequestClientOptions(options);
2441
2564
  this.scheduler = new RestScheduler({
2442
2565
  lanes: normalizeSchedulerLanes(this.options.maxQueueSize, this.options.scheduler?.lanes),
2443
- maxConcurrency: normalizeIntegerOption(this.options.scheduler?.maxConcurrency, DEFAULT_MAX_CONCURRENT_WORKERS, { min: 1 }),
2566
+ maxConcurrency: resolveIntegerOption(this.options.scheduler?.maxConcurrency, DEFAULT_MAX_CONCURRENT_WORKERS, { min: 1 }),
2444
2567
  maxQueueSize: this.options.maxQueueSize,
2445
- maxRateLimitRetries: normalizeIntegerOption(this.options.scheduler?.maxRateLimitRetries, 3, { min: 0 })
2568
+ maxRateLimitRetries: resolveIntegerOption(this.options.scheduler?.maxRateLimitRetries, 3, { min: 0 })
2446
2569
  }, async (request) => await this.executeRequest(request.method, request.path, {
2447
2570
  data: request.data,
2448
2571
  query: request.query
@@ -2540,10 +2663,6 @@ var RequestClient = class {
2540
2663
  this.requestControllers.clear();
2541
2664
  }
2542
2665
  };
2543
- function normalizeIntegerOption(value, fallback, params) {
2544
- const candidate = parseFiniteNumber(value) ?? fallback;
2545
- return Math.max(params.min, Math.floor(candidate));
2546
- }
2547
2666
  function normalizeRequestClientOptions(options) {
2548
2667
  const merged = {
2549
2668
  ...defaultOptions,
@@ -2551,13 +2670,13 @@ function normalizeRequestClientOptions(options) {
2551
2670
  };
2552
2671
  return {
2553
2672
  ...merged,
2554
- apiVersion: normalizeIntegerOption(merged.apiVersion, defaultOptions.apiVersion, { min: 1 }),
2673
+ apiVersion: resolveIntegerOption(merged.apiVersion, defaultOptions.apiVersion, { min: 1 }),
2555
2674
  timeout: clampTimerTimeoutMs(merged.timeout, 1) ?? resolveTimerTimeoutMs(defaultOptions.timeout, 1),
2556
- maxQueueSize: normalizeIntegerOption(merged.maxQueueSize, defaultOptions.maxQueueSize, { min: 1 })
2675
+ maxQueueSize: resolveIntegerOption(merged.maxQueueSize, defaultOptions.maxQueueSize, { min: 1 })
2557
2676
  };
2558
2677
  }
2559
2678
  function normalizeSchedulerLanes(maxQueueSize, lanes) {
2560
- const fallbackMaxQueueSize = normalizeIntegerOption(maxQueueSize, defaultOptions.maxQueueSize, { min: 1 });
2679
+ const fallbackMaxQueueSize = resolveIntegerOption(maxQueueSize, defaultOptions.maxQueueSize, { min: 1 });
2561
2680
  return {
2562
2681
  critical: normalizeSchedulerLane("critical", fallbackMaxQueueSize, lanes?.critical),
2563
2682
  standard: normalizeSchedulerLane("standard", fallbackMaxQueueSize, lanes?.standard),
@@ -2566,11 +2685,11 @@ function normalizeSchedulerLanes(maxQueueSize, lanes) {
2566
2685
  }
2567
2686
  function normalizeSchedulerLane(lane, maxQueueSize, options) {
2568
2687
  const defaults = defaultLaneOptions[lane];
2569
- const staleAfterMs = options?.staleAfterMs !== void 0 ? normalizeIntegerOption(options.staleAfterMs, defaults.staleAfterMs ?? 0, { min: 0 }) : defaults.staleAfterMs;
2688
+ const staleAfterMs = options?.staleAfterMs !== void 0 ? resolveIntegerOption(options.staleAfterMs, defaults.staleAfterMs ?? 0, { min: 0 }) : defaults.staleAfterMs;
2570
2689
  return {
2571
- maxQueueSize: options?.maxQueueSize !== void 0 ? normalizeIntegerOption(options.maxQueueSize, maxQueueSize, { min: 1 }) : maxQueueSize,
2690
+ maxQueueSize: options?.maxQueueSize !== void 0 ? resolveIntegerOption(options.maxQueueSize, maxQueueSize, { min: 1 }) : maxQueueSize,
2572
2691
  ...staleAfterMs !== void 0 ? { staleAfterMs } : {},
2573
- weight: options?.weight !== void 0 ? normalizeIntegerOption(options.weight, defaults.weight, { min: 1 }) : defaults.weight
2692
+ weight: options?.weight !== void 0 ? resolveIntegerOption(options.weight, defaults.weight, { min: 1 }) : defaults.weight
2574
2693
  };
2575
2694
  }
2576
2695
  function getRequestPriority(method, path) {
@@ -2744,6 +2863,12 @@ var ThreadUpdateListener = class extends BaseListener {
2744
2863
  this.type = GatewayDispatchEvents.ThreadUpdate;
2745
2864
  }
2746
2865
  };
2866
+ var ThreadDeleteListener = class extends BaseListener {
2867
+ constructor(..._args12) {
2868
+ super(..._args12);
2869
+ this.type = GatewayDispatchEvents.ThreadDelete;
2870
+ }
2871
+ };
2747
2872
  //#endregion
2748
2873
  //#region extensions/discord/src/internal/discord.ts
2749
2874
  var discord_exports = /* @__PURE__ */ __exportAll({
@@ -2797,6 +2922,7 @@ var discord_exports = /* @__PURE__ */ __exportAll({
2797
2922
  StringSelectMenuInteraction: () => StringSelectMenuInteraction,
2798
2923
  TextDisplay: () => TextDisplay,
2799
2924
  TextInput: () => TextInput,
2925
+ ThreadDeleteListener: () => ThreadDeleteListener,
2800
2926
  ThreadUpdateListener: () => ThreadUpdateListener,
2801
2927
  Thumbnail: () => Thumbnail,
2802
2928
  User: () => User,
@@ -3224,4 +3350,101 @@ function rebalanceReasoningItalics(source, chunks, maxChars) {
3224
3350
  return adjusted;
3225
3351
  }
3226
3352
  //#endregion
3227
- export { Section as $, readDiscordMessage as A, createGuildBan as At, Label as B, listGuildChannels as Bt, Client as C, listChannelMessages as Ct, RateLimitError as D, sendChannelTyping as Dt, DiscordError as E, searchGuildMessages as Et, Message as F, deleteChannelPermission as Ft, ChannelSelectMenu as G, putChannelPermission as Gt, RadioGroup as H, listGuildRoles as Ht, User as I, getGuild as It, LinkButton as J, timeoutGuildMember as Jt, Container as K, removeGuildMember as Kt, serializePayload as L, getGuildMember as Lt, Command as M, createGuildEmoji as Mt, CommandWithSubcommands as N, createGuildScheduledEvent as Nt, isUnknownDiscordVoiceStateError as O, unpinChannelMessage as Ot, Guild as P, createGuildSticker as Pt, Row as Q, Embed as R, getGuildVoiceState as Rt, VoiceStateUpdateListener as S, listChannelArchivedThreads as St, RequestClient as T, pinChannelMessage as Tt, TextInput as U, listGuildScheduledEvents as Ut, Modal as V, listGuildEmojis as Vt, Button as W, moveGuildChannels as Wt, MentionableSelectMenu as X, MediaGallery as Y, __exportAll as Yt, RoleSelectMenu as Z, MessageReactionRemoveListener as _, editChannel as _t, allowFromContainsDiscordUserId as a, BaseMessageInteractiveComponent as at, ResumedListener as b, getChannelMessage as bt, normalizeDiscordOutboundTarget as c, createUserDmChannel as ct, discord_exports as d, deleteOwnMessageReaction as dt, Separator as et, GuildCreateListener as f, listMessageReactionUsers as ft, MessageReactionAddListener as g, deleteChannelMessage as gt, MessageCreateListener as h, deleteChannel as ht, resolveDiscordReplyReference as i, UserSelectMenu as it, readRetryAfter as j, createGuildChannel as jt, readDiscordCode as k, addGuildMemberRole as kt, parseDiscordTarget as l, getCurrentUser as lt, InteractionCreateListener as m, createThread as mt, createReusableDiscordReplyReference as n, TextDisplay as nt, looksLikeDiscordTargetId as o, parseCustomId as ot, GuildDeleteListener as p, createChannelMessage as pt, File as q, removeGuildMemberRole as qt, resolveDiscordReplyMessageId as r, Thumbnail as rt, normalizeDiscordMessagingTarget as s, createChannelWebhook as st, chunkDiscordTextWithMode as t, StringSelectMenu as tt, resolveDiscordChannelId as u, createOwnMessageReaction as ut, PresenceUpdateListener as v, editChannelMessage as vt, Plugin as w, listChannelPins as wt, ThreadUpdateListener as x, getThreadMember as xt, ReadyListener as y, getChannel as yt, CheckboxGroup as z, listGuildActiveThreads as zt };
3353
+ //#region extensions/discord/src/retry.ts
3354
+ const DISCORD_RETRY_DEFAULTS = {
3355
+ attempts: 3,
3356
+ minDelayMs: 500,
3357
+ maxDelayMs: 3e4,
3358
+ jitter: .1
3359
+ };
3360
+ const DISCORD_GATEWAY_RECONNECT_EXTRA_ATTEMPTS = 2;
3361
+ const DISCORD_TRANSIENT_MESSAGE_RE = /\b(?:bad gateway|fetch failed|network error|networkerror|service unavailable|socket hang up|temporarily unavailable|timed out|timeout)\b|connection (?:closed|reset|refused)/i;
3362
+ const ambiguousDiscordMessageCreates = /* @__PURE__ */ new WeakSet();
3363
+ function readDiscordErrorStatus(err) {
3364
+ if (!err || typeof err !== "object") return;
3365
+ return parseStrictNonNegativeInteger("status" in err && err.status !== void 0 ? err.status : "statusCode" in err && err.statusCode !== void 0 ? err.statusCode : void 0);
3366
+ }
3367
+ function classifyDiscordDeliveryFailure(error) {
3368
+ const candidates = collectErrorGraphCandidates(error, (current) => [current.cause, current.error]);
3369
+ for (const candidate of candidates) {
3370
+ const status = readDiscordErrorStatus(candidate);
3371
+ if (status !== void 0) {
3372
+ if (status === 408 || status >= 500) return "ambiguous";
3373
+ if (status >= 400) return "rejected";
3374
+ }
3375
+ }
3376
+ if (candidates.some((candidate) => readErrorName(candidate) === "AbortError" || classifyTransientNetworkErrorCode(extractErrorCode(candidate)) === "ambiguous")) return "ambiguous";
3377
+ if (candidates.some((candidate) => classifyTransientNetworkErrorCode(extractErrorCode(candidate)) === "pre-connect")) return "pre-connect";
3378
+ return candidates.some((candidate) => (candidate instanceof Error || candidate !== null && typeof candidate === "object") && DISCORD_TRANSIENT_MESSAGE_RE.test(formatErrorMessage(candidate))) ? "ambiguous" : "unknown";
3379
+ }
3380
+ function recordDiscordMessageCreateAmbiguity(error) {
3381
+ if (error !== null && typeof error === "object") ambiguousDiscordMessageCreates.add(error);
3382
+ }
3383
+ function hasDiscordMessageCreateAmbiguity(error) {
3384
+ return collectErrorGraphCandidates(error, (current) => [current.cause, current.error]).some((candidate) => candidate !== null && typeof candidate === "object" && ambiguousDiscordMessageCreates.has(candidate));
3385
+ }
3386
+ function hasDiscordRateLimitRejection(error) {
3387
+ return error instanceof RateLimitError || collectErrorGraphCandidates(error, (current) => [current.cause, current.error]).some((candidate) => readDiscordErrorStatus(candidate) === 429);
3388
+ }
3389
+ function isRetryableDiscordTransientError(error) {
3390
+ const failure = classifyDiscordDeliveryFailure(error);
3391
+ return failure === "ambiguous" || failure === "pre-connect" || hasDiscordRateLimitRejection(error);
3392
+ }
3393
+ function isRetryableDiscordPreConnectError(error) {
3394
+ const failure = classifyDiscordDeliveryFailure(error);
3395
+ return failure === "pre-connect" || failure === "rejected" && hasDiscordRateLimitRejection(error);
3396
+ }
3397
+ function resolveDiscordRetryPredicate(safety) {
3398
+ return safety === "non-idempotent-create" ? isRetryableDiscordPreConnectError : isRetryableDiscordTransientError;
3399
+ }
3400
+ function isRetryableDiscordGatewayTransportError(err) {
3401
+ if (!isRetryableDiscordTransientError(err) || err instanceof RateLimitError) return false;
3402
+ return !collectErrorGraphCandidates(err, (current) => [current.cause, current.error]).some((candidate) => readDiscordErrorStatus(candidate) !== void 0);
3403
+ }
3404
+ function createDiscordRetryRunner(params) {
3405
+ const retryConfig = resolveRetryConfig(DISCORD_RETRY_DEFAULTS, params.retry);
3406
+ const attempts = retryConfig.attempts > 1 ? retryConfig.attempts + DISCORD_GATEWAY_RECONNECT_EXTRA_ATTEMPTS : retryConfig.attempts;
3407
+ return (fn, label, options) => {
3408
+ const isRetryable = resolveDiscordRetryPredicate(options?.safety ?? "idempotent");
3409
+ let observedGatewayDisconnect = false;
3410
+ const runRequest = async () => {
3411
+ if (params.signal?.aborted) throw params.signal.reason instanceof Error ? params.signal.reason : /* @__PURE__ */ new Error("Discord request aborted");
3412
+ observedGatewayDisconnect ||= params.isGatewayDisconnected?.() === true;
3413
+ try {
3414
+ return await fn();
3415
+ } catch (err) {
3416
+ observedGatewayDisconnect ||= params.isGatewayDisconnected?.() === true;
3417
+ throw err;
3418
+ }
3419
+ };
3420
+ const shouldRetry = (err, attempt) => isRetryable(err) && (attempt < retryConfig.attempts || observedGatewayDisconnect && isRetryableDiscordGatewayTransportError(err));
3421
+ const retryAfterMs = (err) => err instanceof RateLimitError ? err.retryAfter * 1e3 : void 0;
3422
+ const signal = params.signal;
3423
+ if (signal) return retryAsync(runRequest, {
3424
+ ...retryConfig,
3425
+ attempts,
3426
+ label,
3427
+ shouldRetry,
3428
+ retryAfterMs,
3429
+ sleep: async (delayMs) => {
3430
+ try {
3431
+ await sleepWithAbort(delayMs, signal);
3432
+ } catch (error) {
3433
+ throw signal.aborted && signal.reason instanceof Error ? signal.reason : error;
3434
+ }
3435
+ }
3436
+ });
3437
+ return createChannelApiRetryRunner({
3438
+ retry: {
3439
+ ...retryConfig,
3440
+ attempts
3441
+ },
3442
+ shouldRetry,
3443
+ strictShouldRetry: true,
3444
+ retryAfterMs,
3445
+ verbose: params.verbose
3446
+ })(runRequest, label);
3447
+ };
3448
+ }
3449
+ //#endregion
3450
+ export { LinkButton as $, removeGuildMemberRole as $t, RequestClient as A, listChannelPins as At, Message as B, createGuildSticker as Bt, ReadyListener as C, editChannel as Ct, VoiceStateUpdateListener as D, getThreadMember as Dt, ThreadUpdateListener as E, getChannelMessage as Et, readDiscordMessage as F, addGuildMemberRole as Ft, Label as G, listGuildActiveThreads as Gt, serializePayload as H, getGuild as Ht, readRetryAfter as I, createGuildBan as It, TextInput as J, listGuildRoles as Jt, Modal as K, listGuildChannels as Kt, Command as L, createGuildChannel as Lt, RateLimitError as M, searchGuildMessages as Mt, isUnknownDiscordVoiceStateError as N, sendChannelTyping as Nt, Client as O, listChannelArchivedThreads as Ot, readDiscordCode as P, unpinChannelMessage as Pt, File as Q, removeGuildMember as Qt, CommandWithSubcommands as R, createGuildEmoji as Rt, PresenceUpdateListener as S, deleteChannelMessage as St, ThreadDeleteListener as T, getChannel as Tt, Embed as U, getGuildMember as Ut, User as V, deleteChannelPermission as Vt, CheckboxGroup as W, getGuildVoiceState as Wt, ChannelSelectMenu as X, moveGuildChannels as Xt, Button as Y, listGuildScheduledEvents as Yt, Container as Z, putChannelPermission as Zt, GuildDeleteListener as _, deleteOwnMessageReaction as _t, chunkDiscordTextWithMode as a, Separator as at, MessageReactionAddListener as b, createThread as bt, resolveDiscordReplyReference as c, Thumbnail as ct, normalizeDiscordMessagingTarget as d, parseCustomId as dt, timeoutGuildMember as en, MediaGallery as et, normalizeDiscordOutboundTarget as f, stripUndefinedFields as ft, GuildCreateListener as g, createOwnMessageReaction as gt, discord_exports as h, getCurrentUser as ht, recordDiscordMessageCreateAmbiguity as i, Section as it, DiscordError as j, pinChannelMessage as jt, Plugin as k, listChannelMessages as kt, allowFromContainsDiscordUserId as l, UserSelectMenu as lt, resolveDiscordChannelId as m, createUserDmChannel as mt, createDiscordRetryRunner as n, RoleSelectMenu as nt, createReusableDiscordReplyReference as o, StringSelectMenu as ot, parseDiscordTarget as p, createChannelWebhook as pt, RadioGroup as q, listGuildEmojis as qt, hasDiscordMessageCreateAmbiguity as r, Row as rt, resolveDiscordReplyMessageId as s, TextDisplay as st, classifyDiscordDeliveryFailure as t, __exportAll as tn, MentionableSelectMenu as tt, looksLikeDiscordTargetId as u, BaseMessageInteractiveComponent as ut, InteractionCreateListener as v, listMessageReactionUsers as vt, ResumedListener as w, editChannelMessage as wt, MessageReactionRemoveListener as x, deleteChannel as xt, MessageCreateListener as y, createChannelMessage as yt, Guild as z, createGuildScheduledEvent as zt };