@openclaw/discord 2026.9.6 → 2026.9.7

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 (150) hide show
  1. package/assets/icon.png +0 -0
  2. package/dist/.setup/{account-inspect-BwQj24ht.mjs → account-inspect-De8hOUxG.mjs} +1 -1
  3. package/dist/.setup/{accounts-CwJQoLjM.mjs → accounts-ChaMcixG.mjs} +1 -4
  4. package/dist/.setup/{activities-api-COU4-0nR.mjs → activities-api-tvbsU2e3.mjs} +38 -66
  5. package/dist/.setup/{api-CBK9zcq5.mjs → api-DVbJwZVt.mjs} +10 -2
  6. package/dist/.setup/{approval-handler.runtime-CbBktBb4.mjs → approval-handler.runtime-DxCK2Rux.mjs} +49 -125
  7. package/dist/.setup/{approval-message-updates-jf9zMaIC.mjs → approval-message-updates-BKFqavHZ.mjs} +2 -2
  8. package/dist/.setup/{audit-vKbh-LFR.mjs → audit-CLg9I71N.mjs} +5 -5
  9. package/dist/.setup/{channel-Dv4e3Jpc.mjs → channel-DxlUVU9t.mjs} +121 -227
  10. package/dist/.setup/{channel-type-DKnjV1XW.mjs → channel-type-DRCrEMss.mjs} +22 -22
  11. package/dist/.setup/{channel.setup-0NX6FFwi.mjs → channel.setup-CRo1GjV7.mjs} +6 -9
  12. package/dist/.setup/{components-yBEb75bB.mjs → components-Cq1PvIpN.mjs} +41 -69
  13. package/dist/.setup/{config-schema-CiZz-mtA.mjs → config-schema-oxELUSDx.mjs} +19 -44
  14. package/dist/.setup/{conversation-binding-route-B7qImK_b.mjs → conversation-binding-route-Caz_XuFH.mjs} +10 -5
  15. package/dist/.setup/{directory-config-BytTftz-.mjs → directory-config-esqNn0Eo.mjs} +6 -9
  16. package/dist/.setup/{directory-live--EGTH0DC.mjs → directory-live-DtKRHuGV.mjs} +6 -12
  17. package/dist/.setup/{discord-BXpHW-cu.mjs → discord-0xJYfdDD.mjs} +82 -386
  18. package/dist/.setup/{doctor-D1R-uFIu.mjs → doctor-BCl1H5tl.mjs} +21 -36
  19. package/dist/.setup/{doctor-contract-Co5vRCZ6.mjs → doctor-contract-CvvgwrrG.mjs} +41 -50
  20. package/dist/.setup/{channel-actions.runtime-leZuw01r.mjs → handle-action-CUvQWnE7.mjs} +67 -104
  21. package/dist/.setup/{handle-action.guild-admin-DcFa8NwA.mjs → handle-action.guild-admin-Df-8gVle.mjs} +62 -120
  22. package/dist/.setup/{live-policy-config-eKQ-PLdy.mjs → live-policy-config-8Pv20CHc.mjs} +2 -3
  23. package/dist/.setup/{message-handler-X6ejmbtY.mjs → message-handler-B-Jk4oDk.mjs} +18 -94
  24. package/dist/.setup/{message-handler.preflight-pluralkit-8Xji34AF.mjs → message-handler.preflight-pluralkit-CWLUBVcx.mjs} +8 -10
  25. package/dist/.setup/{message-handler.preflight-DE_POxFc.mjs → message-handler.preflight-v-__NSDq.mjs} +69 -180
  26. package/dist/.setup/{message-handler.process-CCmIVnxy.mjs → message-handler.process-BNFFuChn.mjs} +65 -86
  27. package/dist/.setup/{outbound-adapter-ClIgmu4F.mjs → outbound-adapter-BobT-kse.mjs} +105 -19
  28. package/dist/.setup/{outbound-session-route-VulUE0yV.mjs → outbound-session-route-zVGxxceg.mjs} +140 -108
  29. package/dist/.setup/{pluralkit-CdAt1G0P.mjs → pluralkit-a6_NLfH9.mjs} +1 -1
  30. package/dist/.setup/{presence-cache-dYSHPWMx.mjs → presence-cache-Di3H3DIU.mjs} +0 -4
  31. package/dist/.setup/{probe-CupW4we4.mjs → probe-LYrIHlBF.mjs} +13 -4
  32. package/dist/.setup/{provider-iOf73HW-.mjs → provider-B_G5hASF.mjs} +721 -1416
  33. package/dist/.setup/provider-session.runtime-BYlTBFD2.mjs +6 -0
  34. package/dist/.setup/provider.runtime-CUE3UxER.mjs +2 -0
  35. package/dist/.setup/{realtime-session.runtime-Dz8uVutq.mjs → realtime-session.runtime-oUd9DOcz.mjs} +41 -55
  36. package/dist/.setup/{receive-recovery-DHst8WRx.mjs → receive-recovery-CHPOsnLc.mjs} +1 -4
  37. package/dist/.setup/{resolve-allowlist-common-CwMBzbx9.mjs → resolve-allowlist-common-DPdRggu5.mjs} +4 -7
  38. package/dist/.setup/{resolve-channels-BbvsLQOZ.mjs → resolve-channels-BFPNRmVv.mjs} +21 -40
  39. package/dist/.setup/{resolve-users-ByFlR7LQ.mjs → resolve-users-0-aBuCy3.mjs} +4 -4
  40. package/dist/.setup/{retry-BEYkDy0P.mjs → retry-pz_cSha2.mjs} +3 -3
  41. package/dist/.setup/rolldown-runtime-B4FMCO8f.mjs +28 -0
  42. package/dist/.setup/{runtime-B8lJfyrA.mjs → runtime-FN000lxA.mjs} +60 -162
  43. package/dist/.setup/runtime-doctor-migrations-CshUGl36.mjs +159 -0
  44. package/dist/.setup/{runtime-DisDbixd.mjs → runtime-sUksZ--Q.mjs} +2 -5
  45. package/dist/.setup/{secret-config-contract-DFu9hfU8.mjs → secret-config-contract-uOE2J7yM.mjs} +15 -85
  46. package/dist/.setup/{security-audit-s5w50-Ly.mjs → security-audit-Cdaegq7C.mjs} +3 -1
  47. package/dist/.setup/{send-CIBzvXjS.mjs → send-CrfEI6Bs.mjs} +53 -108
  48. package/dist/.setup/{send.components-ChY21qr-.mjs → send.components-DxQAMfES.mjs} +62 -107
  49. package/dist/.setup/{send.outbound-QTyuFupn.mjs → send.outbound-BISKnb-a.mjs} +66 -140
  50. package/dist/.setup/{send.shared-VNvWfX2T.mjs → send.shared-DGFkbkQR.mjs} +10 -25
  51. package/dist/.setup/{sender-identity-0Ymgvmaj.mjs → sender-identity-B9X5Vb9R.mjs} +2 -3
  52. package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +3 -0
  53. package/dist/.setup/{shared-DHPDaMSx.mjs → shared-B3wZ4hN-.mjs} +25 -32
  54. package/dist/.setup/{subagent-hooks-CjW7r8Pe.mjs → subagent-hooks-nlUE9ow7.mjs} +5 -6
  55. package/dist/.setup/system-events-CdeZnvPV.mjs +33 -0
  56. package/dist/.setup/{target-resolver-BXpy6VT8.mjs → target-resolver-BuLapkhy.mjs} +9 -12
  57. package/dist/.setup/targets-0KUcEIYx.mjs +3 -0
  58. package/dist/.setup/{thread-bindings-CEh2dhqP.mjs → thread-bindings-D7TfgjR_.mjs} +33 -35
  59. package/dist/.setup/{thread-bindings.manager-ve-i6oqt.mjs → thread-bindings.manager-DN-NissX.mjs} +325 -233
  60. package/dist/.setup/thread-bindings.session-updates-CshfKghV.mjs +359 -0
  61. package/dist/.setup/{thread-bindings.state-BThFQEga.mjs → thread-bindings.state-g6v9zAym.mjs} +21 -62
  62. package/dist/.setup/{transcripts-source-DVegW0WI.mjs → transcripts-source-p8EV179h.mjs} +76 -235
  63. package/dist/.setup/{typing-BKZL5fGj.mjs → typing-BiHCzBRu.mjs} +2 -1
  64. package/dist/.setup/{voice-runtime-elTtjEIG.mjs → voice-runtime-B46rcwrG.mjs} +140 -244
  65. package/dist/account-inspect-api.js +1 -1
  66. package/dist/action-runtime-api.js +1 -1
  67. package/dist/activities-api.js +1 -1
  68. package/dist/api.js +18 -18
  69. package/dist/channel-config-api.js +1 -1
  70. package/dist/channel-plugin-api.js +1 -1
  71. package/dist/directory-contract-api.js +1 -1
  72. package/dist/doctor-contract-api.js +4 -4
  73. package/dist/index.js +1 -1
  74. package/dist/runtime-api.js +20 -20
  75. package/dist/secret-contract-api.js +1 -1
  76. package/dist/security-audit-contract-api.js +1 -1
  77. package/dist/setup-entry.js +1 -1
  78. package/dist/setup-plugin-api.js +1 -1
  79. package/dist/src/voice/audio-worker.runtime.js +15 -24
  80. package/dist/subagent-hooks-api.js +3 -4
  81. package/dist/transcripts-source-api.js +1 -1
  82. package/node_modules/@types/node/README.md +2 -2
  83. package/node_modules/@types/node/child_process.d.ts +1 -1
  84. package/node_modules/@types/node/crypto.d.ts +20 -8
  85. package/node_modules/@types/node/ffi.d.ts +14 -0
  86. package/node_modules/@types/node/http2.d.ts +3 -2
  87. package/node_modules/@types/node/net.d.ts +16 -4
  88. package/node_modules/@types/node/package.json +2 -17
  89. package/node_modules/@types/node/process.d.ts +1 -0
  90. package/node_modules/@types/node/quic.d.ts +39 -1
  91. package/node_modules/@types/node/stream/iter.d.ts +9 -12
  92. package/node_modules/@types/node/test/reporters.d.ts +1 -0
  93. package/node_modules/@types/node/test.d.ts +72 -0
  94. package/node_modules/@types/node/tls.d.ts +14 -10
  95. package/node_modules/@types/node/vm.d.ts +2 -1
  96. package/node_modules/@types/node/worker_threads.d.ts +4 -1
  97. package/node_modules/typebox/build/compile/code.mjs +1 -2
  98. package/node_modules/typebox/build/compile/validator.mjs +5 -1
  99. package/node_modules/typebox/build/format/iri.mjs +16 -9
  100. package/node_modules/typebox/build/guard/emit.mjs +2 -2
  101. package/node_modules/typebox/build/guard/guard.d.mts +7 -5
  102. package/node_modules/typebox/build/guard/guard.mjs +14 -9
  103. package/node_modules/typebox/build/guard/index.mjs +6 -0
  104. package/node_modules/typebox/build/guard/unicode/unicode.d.mts +6 -0
  105. package/node_modules/typebox/build/guard/unicode/unicode.mjs +35 -0
  106. package/node_modules/typebox/build/guard/{string.mjs → unicode/unicode_segment.mjs} +16 -19
  107. package/node_modules/typebox/build/schema/build.mjs +2 -3
  108. package/node_modules/typebox/build/schema/engine/_pathing.d.mts +1 -0
  109. package/node_modules/typebox/build/schema/engine/_pathing.mjs +11 -0
  110. package/node_modules/typebox/build/schema/engine/_refine.mjs +13 -5
  111. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +2 -1
  112. package/node_modules/typebox/build/schema/engine/dependencies.mjs +2 -1
  113. package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +2 -1
  114. package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +1 -1
  115. package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +2 -2
  116. package/node_modules/typebox/build/schema/engine/format.mjs +9 -2
  117. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +3 -2
  118. package/node_modules/typebox/build/schema/engine/properties.mjs +3 -2
  119. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -1
  120. package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +1 -1
  121. package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +2 -2
  122. package/node_modules/typebox/build/schema/engine/ref.d.mts +1 -1
  123. package/node_modules/typebox/build/schema/engine/ref.mjs +2 -2
  124. package/node_modules/typebox/build/schema/engine/schema.mjs +24 -24
  125. package/node_modules/typebox/build/schema/parse.mjs +3 -0
  126. package/node_modules/typebox/build/schema/pointer/pointer.d.mts +1 -6
  127. package/node_modules/typebox/build/schema/pointer/pointer.mjs +47 -64
  128. package/node_modules/typebox/build/system/settings/internal.d.mts +2 -0
  129. package/node_modules/typebox/build/system/settings/internal.mjs +20 -0
  130. package/node_modules/typebox/build/system/settings/settings.d.mts +11 -0
  131. package/node_modules/typebox/build/system/settings/settings.mjs +14 -0
  132. package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
  133. package/node_modules/typebox/build/type/extends/inference.mjs +15 -2
  134. package/node_modules/typebox/build/type/extends/tuple.d.mts +2 -1
  135. package/node_modules/typebox/build/type/extends/tuple.mjs +21 -1
  136. package/node_modules/typebox/build/value/parse/parse.mjs +10 -4
  137. package/node_modules/typebox/package.json +1 -1
  138. package/node_modules/typebox/readme.md +3 -1
  139. package/openclaw.plugin.json +21 -1
  140. package/package.json +5 -5
  141. package/dist/.setup/agent-components.runtime-CEPrf2SY.mjs +0 -4
  142. package/dist/.setup/probe.runtime-DBQ_AGPe.mjs +0 -2
  143. package/dist/.setup/provider-session.runtime-DrGAYnZv.mjs +0 -6
  144. package/dist/.setup/provider.runtime-BmjW_pIw.mjs +0 -2
  145. package/dist/.setup/security-audit.runtime-DHtYenx9.mjs +0 -2
  146. package/dist/.setup/setup-plugin-api-Dvr41dyx.mjs +0 -3
  147. package/dist/.setup/system-events-B2YEEMbS.mjs +0 -34
  148. package/dist/.setup/targets-CvemhN3i.mjs +0 -3
  149. package/dist/.setup/thread-bindings.session-updates-DCQq1WZ5.mjs +0 -55
  150. /package/node_modules/typebox/build/guard/{string.d.mts → unicode/unicode_segment.d.mts} +0 -0
@@ -1,9 +1,10 @@
1
- import { A as serializePayload, C as withDiscordRequestAuthority, Ut as __exportAll, ft as editChannelMessage, st as createChannelMessage } from "./discord-BXpHW-cu.mjs";
2
- import { d as buildDiscordComponentMessage, f as buildDiscordComponentMessageFlags, g as resolveDiscordComponentAttachmentName } from "./components-yBEb75bB.mjs";
1
+ import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
2
+ import { d as buildDiscordComponentMessage, f as buildDiscordComponentMessageFlags, g as resolveDiscordComponentAttachmentName } from "./components-Cq1PvIpN.mjs";
3
+ import { A as serializePayload, C as withDiscordRequestAuthority, ct as createChannelMessage, pt as editChannelMessage } from "./discord-0xJYfdDD.mjs";
3
4
  import { n as getOptionalDiscordRuntime } from "./runtime-DgnVQ7zW.mjs";
4
- import { l as createDiscordSendResult } from "./retry-BEYkDy0P.mjs";
5
- import { E as SUPPRESS_NOTIFICATIONS_FLAG, K as parseAndResolveChannelRecipient, N as createDiscordClient, O as createDiscordMessageNonce, l as resolveChannelId, t as buildDiscordSendError, u as resolveDiscordChannel } from "./send.shared-VNvWfX2T.mjs";
6
- import { t as sendMessageDiscord } from "./send.outbound-QTyuFupn.mjs";
5
+ import { u as createDiscordSendResult } from "./retry-pz_cSha2.mjs";
6
+ import { D as createDiscordMessageNonce, G as parseAndResolveChannelRecipient, M as createDiscordClient, T as SUPPRESS_NOTIFICATIONS_FLAG, c as resolveChannelId, l as resolveDiscordChannel, t as buildDiscordSendError } from "./send.shared-DGFkbkQR.mjs";
7
+ import { t as sendMessageDiscord } from "./send.outbound-BISKnb-a.mjs";
7
8
  import { ChannelType } from "discord-api-types/v10";
8
9
  import { asDateTimestampMs, isFutureDateTimestampMs, resolveDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
9
10
  import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
@@ -36,12 +37,6 @@ const PERSISTENT_COMPONENT_NAMESPACE = "discord.components";
36
37
  const PERSISTENT_MODAL_NAMESPACE = "discord.modals";
37
38
  const PERSISTENT_COMPONENT_MAX_ENTRIES = 500;
38
39
  const PERSISTENT_MODAL_MAX_ENTRIES = 500;
39
- function getComponentEntries() {
40
- return discordComponentRegistryState.componentEntries;
41
- }
42
- function getModalEntries() {
43
- return discordComponentRegistryState.modalEntries;
44
- }
45
40
  function formatRegistryError(error) {
46
41
  if (!(error instanceof Error)) return { error: formatRegistryErrorValue(error) };
47
42
  const details = {
@@ -133,15 +128,10 @@ function pruneUndefinedRegistryValues(value) {
133
128
  return result;
134
129
  }
135
130
  function normalizeRegistryEntries(entries, params) {
136
- const normalizedEntries = [];
137
- for (const entry of entries) {
138
- const normalized = normalizeEntryTimestamps({
139
- ...entry,
140
- messageId: params.messageId ?? entry.messageId
141
- }, params.now, params.ttlMs);
142
- normalizedEntries.push(normalized);
143
- }
144
- return normalizedEntries;
131
+ return entries.map((entry) => normalizeEntryTimestamps({
132
+ ...entry,
133
+ messageId: params.messageId ?? entry.messageId
134
+ }, params.now, params.ttlMs));
145
135
  }
146
136
  function resolveEntry(store, params) {
147
137
  const entry = store.get(params.id);
@@ -199,7 +189,7 @@ function resolveComponentConsumptionIds(entry) {
199
189
  return ids.length > 0 ? uniqueStrings(ids) : [entry.id];
200
190
  }
201
191
  function deleteComponentConsumptionGroup(entry) {
202
- const store = getComponentEntries();
192
+ const store = discordComponentRegistryState.componentEntries;
203
193
  for (const id of resolveComponentConsumptionIds(entry)) store.delete(id);
204
194
  }
205
195
  async function deletePersistentComponentConsumptionGroup(entry) {
@@ -232,8 +222,8 @@ function registerDiscordComponentEntries(params) {
232
222
  messageId: params.messageId
233
223
  });
234
224
  return discordComponentRegistryState.withRegistryLock(async () => {
235
- for (const entry of normalizedEntries) getComponentEntries().set(entry.id, entry);
236
- for (const entry of normalizedModals) getModalEntries().set(entry.id, entry);
225
+ for (const entry of normalizedEntries) discordComponentRegistryState.componentEntries.set(entry.id, entry);
226
+ for (const entry of normalizedModals) discordComponentRegistryState.modalEntries.set(entry.id, entry);
237
227
  await registerPersistentEntries({
238
228
  entries: normalizedEntries,
239
229
  modals: normalizedModals,
@@ -242,7 +232,7 @@ function registerDiscordComponentEntries(params) {
242
232
  });
243
233
  }
244
234
  function resolveDiscordComponentEntry(params) {
245
- const entry = resolveEntry(getComponentEntries(), params);
235
+ const entry = resolveEntry(discordComponentRegistryState.componentEntries, params);
246
236
  if (entry && params.consume !== false) deleteComponentConsumptionGroup(entry);
247
237
  return entry;
248
238
  }
@@ -261,12 +251,9 @@ async function resolveDiscordComponentEntryWithPersistence(params) {
261
251
  return persisted;
262
252
  });
263
253
  }
264
- function resolveDiscordModalEntry(params) {
265
- return resolveEntry(getModalEntries(), params);
266
- }
267
254
  async function resolveDiscordModalEntryWithPersistence(params) {
268
255
  return discordComponentRegistryState.withRegistryLock(async () => {
269
- const inMemory = resolveDiscordModalEntry(params);
256
+ const inMemory = resolveEntry(discordComponentRegistryState.modalEntries, params);
270
257
  if (inMemory) {
271
258
  if (params.consume !== false) await deletePersistentEntry({
272
259
  ...params,
@@ -387,57 +374,66 @@ async function buildDiscordComponentPayload(params) {
387
374
  };
388
375
  }
389
376
  async function sendDiscordComponentMessage(to, spec, opts) {
390
- return await withDiscordRequestAuthority(opts.assertPlatformSendAuthorized, () => sendDiscordComponentMessageInternal(to, spec, opts));
391
- }
392
- async function sendDiscordComponentMessageInternal(to, spec, opts) {
393
- const classicMessage = opts.mediaUrl ? resolveClassicDiscordMessage(spec) : void 0;
394
- if (classicMessage) return await sendMessageDiscord(to, classicMessage.text, {
395
- cfg: opts.cfg,
396
- accountId: opts.accountId,
397
- token: opts.token,
398
- rest: opts.rest,
399
- mediaUrl: opts.mediaUrl,
400
- filename: opts.filename?.trim() || classicMessage.filename,
401
- mediaLocalRoots: opts.mediaLocalRoots,
402
- mediaReadFile: opts.mediaReadFile,
403
- mediaAccess: opts.mediaAccess,
404
- reply: opts.reply,
405
- silent: opts.silent,
406
- textLimit: opts.textLimit,
407
- maxLinesPerMessage: opts.maxLinesPerMessage,
408
- tableMode: opts.tableMode,
409
- chunkMode: opts.chunkMode,
410
- onDeliveryResult: opts.onDeliveryResult,
411
- onPlatformSendDispatch: opts.onPlatformSendDispatch,
412
- assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized,
413
- ...opts.suppressEmbeds === void 0 ? {} : { suppressEmbeds: opts.suppressEmbeds }
377
+ return await withDiscordRequestAuthority(opts.assertPlatformSendAuthorized, async () => {
378
+ const classicMessage = opts.mediaUrl ? resolveClassicDiscordMessage(spec) : void 0;
379
+ if (classicMessage) return await sendMessageDiscord(to, classicMessage.text, {
380
+ cfg: opts.cfg,
381
+ accountId: opts.accountId,
382
+ token: opts.token,
383
+ rest: opts.rest,
384
+ mediaUrl: opts.mediaUrl,
385
+ filename: opts.filename?.trim() || classicMessage.filename,
386
+ mediaLocalRoots: opts.mediaLocalRoots,
387
+ mediaReadFile: opts.mediaReadFile,
388
+ mediaAccess: opts.mediaAccess,
389
+ reply: opts.reply,
390
+ silent: opts.silent,
391
+ textLimit: opts.textLimit,
392
+ maxLinesPerMessage: opts.maxLinesPerMessage,
393
+ tableMode: opts.tableMode,
394
+ chunkMode: opts.chunkMode,
395
+ onDeliveryResult: opts.onDeliveryResult,
396
+ onPlatformSendDispatch: opts.onPlatformSendDispatch,
397
+ assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized,
398
+ ...opts.suppressEmbeds === void 0 ? {} : { suppressEmbeds: opts.suppressEmbeds }
399
+ });
400
+ return await writeDiscordComponentMessage(to, spec, opts);
414
401
  });
415
- const cfg = requireRuntimeConfig(opts.cfg, "Discord component send");
402
+ }
403
+ async function editDiscordComponentMessage(to, messageId, spec, opts) {
404
+ return await writeDiscordComponentMessage(to, spec, opts, messageId);
405
+ }
406
+ async function writeDiscordComponentMessage(to, spec, opts, messageId) {
407
+ const creating = messageId === void 0;
408
+ const cfg = requireRuntimeConfig(opts.cfg, creating ? "Discord component send" : "Discord component edit");
416
409
  const { token, rest, request, account: accountInfo } = createDiscordClient({
417
410
  ...opts,
418
411
  cfg
419
412
  });
420
413
  const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
421
414
  const { channelId } = await resolveChannelId(rest, recipient, request);
422
- const channel = await resolveDiscordChannel(rest, channelId);
423
- if (channel && DISCORD_FORUM_LIKE_TYPES.has(channel.type)) throw new Error("Discord components are not supported in forum-style channels");
415
+ if (creating) {
416
+ const channel = await resolveDiscordChannel(rest, channelId);
417
+ if (channel && DISCORD_FORUM_LIKE_TYPES.has(channel.type)) throw new Error("Discord components are not supported in forum-style channels");
418
+ }
424
419
  const { body: componentBody, buildResult } = await buildDiscordComponentPayload({
425
420
  spec,
426
421
  opts,
427
422
  accountId: accountInfo.accountId
428
423
  });
429
- const body = {
424
+ const body = creating ? {
430
425
  ...componentBody,
431
426
  nonce: createDiscordMessageNonce(),
432
427
  enforce_nonce: true
433
- };
428
+ } : componentBody;
434
429
  let result;
435
430
  try {
436
431
  result = await request(async () => {
432
+ if (messageId !== void 0) return editChannelMessage(rest, channelId, messageId, { body });
437
433
  await opts.onPlatformSendDispatch?.();
438
434
  opts.assertPlatformSendAuthorized?.();
439
435
  return createChannelMessage(rest, channelId, { body });
440
- }, "components", { safety: "nonce-protected-create" });
436
+ }, "components", creating ? { safety: "nonce-protected-create" } : void 0);
441
437
  } catch (err) {
442
438
  throw await buildDiscordSendError(err, {
443
439
  channelId,
@@ -447,50 +443,17 @@ async function sendDiscordComponentMessageInternal(to, spec, opts) {
447
443
  hasMedia: Boolean(opts.mediaUrl)
448
444
  });
449
445
  }
450
- const deliveryResult = createDiscordSendResult({
451
- result,
446
+ const toDeliveryResult = () => createDiscordSendResult({
447
+ result: creating ? result : {
448
+ id: result.id ?? messageId,
449
+ channel_id: result.channel_id
450
+ },
452
451
  fallbackChannelId: channelId,
453
452
  kind: "card",
454
453
  ...opts.reply ? { reply: opts.reply } : {}
455
454
  });
456
- await opts.onDeliveryResult?.(deliveryResult);
457
- await registerBuiltDiscordComponentMessage({
458
- buildResult,
459
- messageId: result.id,
460
- ttlMs: resolveDiscordComponentRegistryTtlMs(accountInfo.config)
461
- });
462
- recordChannelActivity({
463
- channel: "discord",
464
- accountId: accountInfo.accountId,
465
- direction: "outbound"
466
- });
467
- return deliveryResult;
468
- }
469
- async function editDiscordComponentMessage(to, messageId, spec, opts) {
470
- const cfg = requireRuntimeConfig(opts.cfg, "Discord component edit");
471
- const { token, rest, request, account: accountInfo } = createDiscordClient({
472
- ...opts,
473
- cfg
474
- });
475
- const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
476
- const { channelId } = await resolveChannelId(rest, recipient, request);
477
- const { body, buildResult } = await buildDiscordComponentPayload({
478
- spec,
479
- opts,
480
- accountId: accountInfo.accountId
481
- });
482
- let result;
483
- try {
484
- result = await request(() => editChannelMessage(rest, channelId, messageId, { body }), "components");
485
- } catch (err) {
486
- throw await buildDiscordSendError(err, {
487
- channelId,
488
- cfg,
489
- rest,
490
- token,
491
- hasMedia: Boolean(opts.mediaUrl)
492
- });
493
- }
455
+ const deliveryResult = creating ? toDeliveryResult() : void 0;
456
+ if (deliveryResult) await opts.onDeliveryResult?.(deliveryResult);
494
457
  await registerBuiltDiscordComponentMessage({
495
458
  buildResult,
496
459
  messageId: result.id ?? messageId,
@@ -501,15 +464,7 @@ async function editDiscordComponentMessage(to, messageId, spec, opts) {
501
464
  accountId: accountInfo.accountId,
502
465
  direction: "outbound"
503
466
  });
504
- return createDiscordSendResult({
505
- result: {
506
- id: result.id ?? messageId,
507
- channel_id: result.channel_id
508
- },
509
- fallbackChannelId: channelId,
510
- kind: "card",
511
- ...opts.reply ? { reply: opts.reply } : {}
512
- });
467
+ return deliveryResult ?? toDeliveryResult();
513
468
  }
514
469
  //#endregion
515
470
  export { registerDiscordComponentEntries as a, send_components_exports as i, registerBuiltDiscordComponentMessage as n, resolveDiscordComponentEntryWithPersistence as o, sendDiscordComponentMessage as r, resolveDiscordModalEntryWithPersistence as s, editDiscordComponentMessage as t };
@@ -1,7 +1,7 @@
1
- import { C as withDiscordRequestAuthority, ct as createThread, st as createChannelMessage } from "./discord-BXpHW-cu.mjs";
2
- import { i as normalizeDiscordHandleKey, o as resolveDiscordDirectoryUserId } from "./directory-live--EGTH0DC.mjs";
3
- import { c as createDiscordSendReceiptFromResults, d as createReusableDiscordReplyReference, l as createDiscordSendResult } from "./retry-BEYkDy0P.mjs";
4
- import { A as resolveDiscordSendComponents, D as buildDiscordMessageRequest, K as parseAndResolveChannelRecipient, M as resolveDiscordSuppressEmbeds, N as createDiscordClient, O as createDiscordMessageNonce, a as normalizeDiscordPollInput, c as normalizeStickerIds, f as sendDiscordMedia, j as resolveDiscordSendEmbeds, k as resolveDiscordMessageFlags, l as resolveChannelId, n as buildDiscordTextChunks, p as sendDiscordText, t as buildDiscordSendError, u as resolveDiscordChannel } from "./send.shared-VNvWfX2T.mjs";
1
+ import { C as withDiscordRequestAuthority, ct as createChannelMessage, lt as createThread } from "./discord-0xJYfdDD.mjs";
2
+ import { i as normalizeDiscordHandleKey, o as resolveDiscordDirectoryUserId } from "./directory-live-DtKRHuGV.mjs";
3
+ import { f as createReusableDiscordReplyReference, l as createDiscordSendReceiptFromResults, u as createDiscordSendResult } from "./retry-pz_cSha2.mjs";
4
+ import { A as resolveDiscordSendEmbeds, D as createDiscordMessageNonce, E as buildDiscordMessageRequest, G as parseAndResolveChannelRecipient, M as createDiscordClient, O as resolveDiscordMessageFlags, c as resolveChannelId, d as sendDiscordMedia, f as sendDiscordText, i as normalizeDiscordPollInput, j as resolveDiscordSuppressEmbeds, k as resolveDiscordSendComponents, l as resolveDiscordChannel, n as buildDiscordTextChunks, s as normalizeStickerIds, t as buildDiscordSendError } from "./send.shared-DGFkbkQR.mjs";
5
5
  import { ChannelType } from "discord-api-types/v10";
6
6
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
7
7
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -26,25 +26,13 @@ function formatMention(params) {
26
26
  const userId = params.userId == null ? null : normalizeSnowflake(params.userId);
27
27
  const roleId = params.roleId == null ? null : normalizeSnowflake(params.roleId);
28
28
  const channelId = params.channelId == null ? null : normalizeSnowflake(params.channelId);
29
- const values = [
30
- userId ? {
31
- kind: "user",
32
- id: userId
33
- } : null,
34
- roleId ? {
35
- kind: "role",
36
- id: roleId
37
- } : null,
38
- channelId ? {
39
- kind: "channel",
40
- id: channelId
41
- } : null
29
+ const mentions = [
30
+ userId ? `<@${userId}>` : null,
31
+ roleId ? `<@&${roleId}>` : null,
32
+ channelId ? `<#${channelId}>` : null
42
33
  ].filter((entry) => Boolean(entry));
43
- if (values.length !== 1) throw new Error("formatMention requires exactly one of userId, roleId, or channelId");
44
- const target = expectDefined(values.at(0), "single Discord mention target");
45
- if (target.kind === "user") return `<@${target.id}>`;
46
- if (target.kind === "role") return `<@&${target.id}>`;
47
- return `<#${target.id}>`;
34
+ if (mentions.length !== 1) throw new Error("formatMention requires exactly one of userId, roleId, or channelId");
35
+ return expectDefined(mentions.at(0), "single Discord mention target");
48
36
  }
49
37
  function resolveConfiguredMentionAlias(handle, mentionAliases) {
50
38
  const key = normalizeDiscordHandleKey(handle);
@@ -393,23 +381,6 @@ function prepareDiscordOutboundText(text, params) {
393
381
  const DEFAULT_DISCORD_MEDIA_MAX_MB = 100;
394
382
  /** Discord's ChannelFlags.RequireTag is bit 4 on forum/media parent channels. */
395
383
  const DISCORD_FORUM_REQUIRE_TAG_FLAG = 16;
396
- async function sendDiscordThreadTextChunks(params) {
397
- for (const chunk of params.chunks) await sendDiscordText({
398
- rest: params.rest,
399
- channelId: params.threadId,
400
- text: chunk,
401
- request: params.request,
402
- maxLinesPerMessage: params.maxLinesPerMessage,
403
- chunkMode: params.chunkMode,
404
- silent: params.silent,
405
- suppressEmbeds: params.suppressEmbeds,
406
- allowedMentions: params.allowedMentions,
407
- maxChars: params.maxChars,
408
- onResult: params.onResult,
409
- onPlatformSendDispatch: params.onPlatformSendDispatch,
410
- assertPlatformSendAuthorized: params.assertPlatformSendAuthorized
411
- });
412
- }
413
384
  /** Discord thread names are capped at 100 characters. */
414
385
  const DISCORD_THREAD_NAME_LIMIT = 100;
415
386
  /** Derive a thread title from the first non-empty line of the message text. */
@@ -421,16 +392,6 @@ function deriveForumThreadName(text) {
421
392
  function isForumLikeChannel(channel) {
422
393
  return channel?.type === ChannelType.GuildForum || channel?.type === ChannelType.GuildMedia;
423
394
  }
424
- function toDiscordSendResult(result, fallbackChannelId, params = {}) {
425
- const resultParams = {
426
- result,
427
- fallbackChannelId,
428
- kind: params.kind ?? "text"
429
- };
430
- if (params.threadId != null) resultParams.threadId = params.threadId;
431
- if (params.reply) resultParams.reply = params.reply;
432
- return createDiscordSendResult(resultParams);
433
- }
434
395
  async function resolveDiscordSendTarget(to, opts) {
435
396
  const cfg = requireRuntimeConfig(opts.cfg, "Discord send target resolution");
436
397
  const { rest, request, account } = createDiscordClient({
@@ -474,7 +435,9 @@ async function sendMessageDiscordInternal(to, text, opts) {
474
435
  const deliveredResults = [];
475
436
  let deliveryThreadId;
476
437
  const reportResult = async (progressResult, kind, replyToId) => {
477
- const deliveredResult = toDiscordSendResult(progressResult, deliveryThreadId ?? channelId, {
438
+ const deliveredResult = createDiscordSendResult({
439
+ result: progressResult,
440
+ fallbackChannelId: deliveryThreadId ?? channelId,
478
441
  kind,
479
442
  threadId: deliveryThreadId,
480
443
  reply: createReusableDiscordReplyReference(replyToId)
@@ -482,6 +445,26 @@ async function sendMessageDiscordInternal(to, text, opts) {
482
445
  deliveredResults.push(deliveredResult);
483
446
  await opts.onDeliveryResult?.(deliveredResult);
484
447
  };
448
+ const textSendOptions = {
449
+ rest,
450
+ request,
451
+ maxLinesPerMessage,
452
+ chunkMode,
453
+ silent: opts.silent,
454
+ suppressEmbeds,
455
+ allowedMentions: opts.allowedMentions,
456
+ maxChars: textLimit,
457
+ onResult: reportResult,
458
+ onPlatformSendDispatch: opts.onPlatformSendDispatch,
459
+ assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
460
+ };
461
+ const mediaSendOptions = {
462
+ filename: opts.filename,
463
+ mediaAccess: opts.mediaAccess,
464
+ mediaLocalRoots: opts.mediaLocalRoots,
465
+ mediaReadFile: opts.mediaReadFile,
466
+ maxBytes: mediaMaxBytes
467
+ };
485
468
  if (isForumLikeChannel(channel)) {
486
469
  if (((channel.flags ?? 0) & DISCORD_FORUM_REQUIRE_TAG_FLAG) !== 0) throw new Error(`Discord forum channel ${channelId} requires an applied tag; use thread-create with appliedTags, then send to the created thread.`);
487
470
  const threadName = deriveForumThreadName(renderedText);
@@ -537,68 +520,34 @@ async function sendMessageDiscordInternal(to, text, opts) {
537
520
  const messageId = threadRes.message?.id ?? threadId;
538
521
  const resultChannelId = threadRes.message?.channel_id ?? threadId;
539
522
  const remainingChunks = chunks.slice(1);
540
- const starterResult = toDiscordSendResult({
541
- id: messageId,
542
- channel_id: resultChannelId
543
- }, channelId, {
523
+ const starterResult = createDiscordSendResult({
524
+ result: {
525
+ id: messageId,
526
+ channel_id: resultChannelId
527
+ },
528
+ fallbackChannelId: channelId,
544
529
  kind: "text",
545
530
  threadId
546
531
  });
547
532
  deliveredResults.push(starterResult);
548
533
  await opts.onDeliveryResult?.(starterResult);
549
534
  try {
535
+ let textChunks = remainingChunks;
550
536
  if (opts.mediaUrl) {
551
537
  const [mediaCaption, ...afterMediaChunks] = remainingChunks;
552
538
  await sendDiscordMedia({
553
- rest,
539
+ ...textSendOptions,
540
+ ...mediaSendOptions,
554
541
  channelId: threadId,
555
542
  text: mediaCaption ?? "",
556
- mediaUrl: opts.mediaUrl,
557
- filename: opts.filename,
558
- mediaAccess: opts.mediaAccess,
559
- mediaLocalRoots: opts.mediaLocalRoots,
560
- mediaReadFile: opts.mediaReadFile,
561
- maxBytes: mediaMaxBytes,
562
- request,
563
- maxLinesPerMessage,
564
- chunkMode,
565
- silent: opts.silent,
566
- suppressEmbeds,
567
- allowedMentions: opts.allowedMentions,
568
- maxChars: textLimit,
569
- onResult: reportResult,
570
- onPlatformSendDispatch: opts.onPlatformSendDispatch,
571
- assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
572
- });
573
- await sendDiscordThreadTextChunks({
574
- rest,
575
- threadId,
576
- chunks: afterMediaChunks,
577
- request,
578
- maxLinesPerMessage,
579
- chunkMode,
580
- maxChars: textLimit,
581
- silent: opts.silent,
582
- suppressEmbeds,
583
- allowedMentions: opts.allowedMentions,
584
- onResult: reportResult,
585
- onPlatformSendDispatch: opts.onPlatformSendDispatch,
586
- assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
543
+ mediaUrl: opts.mediaUrl
587
544
  });
588
- } else await sendDiscordThreadTextChunks({
589
- rest,
590
- threadId,
591
- chunks: remainingChunks,
592
- request,
593
- maxLinesPerMessage,
594
- chunkMode,
595
- maxChars: textLimit,
596
- silent: opts.silent,
597
- suppressEmbeds,
598
- allowedMentions: opts.allowedMentions,
599
- onResult: reportResult,
600
- onPlatformSendDispatch: opts.onPlatformSendDispatch,
601
- assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
545
+ textChunks = afterMediaChunks;
546
+ }
547
+ for (const chunk of textChunks) await sendDiscordText({
548
+ ...textSendOptions,
549
+ channelId: threadId,
550
+ text: chunk
602
551
  });
603
552
  } catch (err) {
604
553
  throw await buildDiscordSendError(err, {
@@ -624,48 +573,19 @@ async function sendMessageDiscordInternal(to, text, opts) {
624
573
  }
625
574
  let result;
626
575
  try {
627
- if (opts.mediaUrl) result = await sendDiscordMedia({
628
- rest,
629
- channelId,
630
- text: textWithMentions,
631
- mediaUrl: opts.mediaUrl,
632
- filename: opts.filename,
633
- mediaAccess: opts.mediaAccess,
634
- mediaLocalRoots: opts.mediaLocalRoots,
635
- mediaReadFile: opts.mediaReadFile,
636
- maxBytes: mediaMaxBytes,
637
- reply: opts.reply,
638
- request,
639
- maxLinesPerMessage,
640
- components: opts.components,
641
- embeds: opts.embeds,
642
- chunkMode,
643
- silent: opts.silent,
644
- suppressEmbeds,
645
- allowedMentions: opts.allowedMentions,
646
- maxChars: textLimit,
647
- onResult: reportResult,
648
- onPlatformSendDispatch: opts.onPlatformSendDispatch,
649
- assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
650
- });
651
- else result = await sendDiscordText({
652
- rest,
576
+ const message = {
577
+ ...textSendOptions,
653
578
  channelId,
654
579
  text: textWithMentions,
655
580
  reply: opts.reply,
656
- request,
657
- maxLinesPerMessage,
658
581
  components: opts.components,
659
- embeds: opts.embeds,
660
- chunkMode,
661
- silent: opts.silent,
662
- suppressEmbeds,
663
- allowedMentions: opts.allowedMentions,
664
- maxChars: textLimit,
665
- onResult: reportResult,
666
- onPlatformSendDispatch: opts.onPlatformSendDispatch,
667
- assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
668
- });
582
+ embeds: opts.embeds
583
+ };
584
+ result = opts.mediaUrl ? await sendDiscordMedia({
585
+ ...message,
586
+ ...mediaSendOptions,
587
+ mediaUrl: opts.mediaUrl
588
+ }) : await sendDiscordText(message);
669
589
  } catch (err) {
670
590
  throw await buildDiscordSendError(err, {
671
591
  channelId,
@@ -681,7 +601,11 @@ async function sendMessageDiscordInternal(to, text, opts) {
681
601
  direction: "outbound"
682
602
  });
683
603
  return {
684
- ...toDiscordSendResult(result, channelId),
604
+ ...createDiscordSendResult({
605
+ result,
606
+ fallbackChannelId: channelId,
607
+ kind: "text"
608
+ }),
685
609
  receipt: createDiscordSendReceiptFromResults({ results: deliveredResults })
686
610
  };
687
611
  }
@@ -742,7 +666,9 @@ async function resolveDiscordStructuredSendContext(to, opts) {
742
666
  accountId: accountInfo.accountId,
743
667
  direction: "outbound"
744
668
  });
745
- return toDiscordSendResult(result, channelId, {
669
+ return createDiscordSendResult({
670
+ result,
671
+ fallbackChannelId: channelId,
746
672
  kind: kind === "poll" ? "poll" : "card",
747
673
  threadId: kind === "poll" ? opts.threadId : void 0
748
674
  });
@@ -1,8 +1,8 @@
1
- import { A as serializePayload, At as getGuild, g as RequestClient, ht as getThreadMember, j as Embed, jt as getGuildMember, k as hasDiscordV2Components, nt as createUserDmChannel, pt as getChannel, rt as getCurrentUser, st as createChannelMessage } from "./discord-BXpHW-cu.mjs";
2
- import { t as isDiscordThreadChannelType } from "./channel-type-DKnjV1XW.mjs";
3
- import { c as resolveDiscordAccount, m as normalizeDiscordToken, o as mergeDiscordAccountConfig } from "./accounts-CwJQoLjM.mjs";
4
- import { f as resolveDiscordReplyMessageId, o as chunkDiscordTextWithMode, r as createDiscordRetryRunner } from "./retry-BEYkDy0P.mjs";
5
- import { t as parseAndResolveDiscordTarget } from "./target-resolver-BXpy6VT8.mjs";
1
+ import { A as serializePayload, Mt as getGuildMember, ct as createChannelMessage, g as RequestClient, gt as getThreadMember, it as getCurrentUser, j as Embed, jt as getGuild, k as hasDiscordV2Components, mt as getChannel, rt as createUserDmChannel } from "./discord-0xJYfdDD.mjs";
2
+ import { t as isDiscordThreadChannelType } from "./channel-type-DRCrEMss.mjs";
3
+ import { c as resolveDiscordAccount, m as normalizeDiscordToken, o as mergeDiscordAccountConfig } from "./accounts-ChaMcixG.mjs";
4
+ import { o as chunkDiscordTextWithMode, p as resolveDiscordReplyMessageId, r as createDiscordRetryRunner } from "./retry-pz_cSha2.mjs";
5
+ import { t as parseAndResolveDiscordTarget } from "./target-resolver-BuLapkhy.mjs";
6
6
  import { ChannelType, MessageFlags, PermissionFlagsBits } from "discord-api-types/v10";
7
7
  import { randomBytes } from "node:crypto";
8
8
  import { makeProxyFetch } from "openclaw/plugin-sdk/fetch-runtime";
@@ -55,19 +55,15 @@ const DEFAULT_ACCOUNT_KEY = "\0__default__";
55
55
  function resolveAccountKey(accountId) {
56
56
  return accountId ?? DEFAULT_ACCOUNT_KEY;
57
57
  }
58
- /** Register a GatewayPlugin instance for an account. */
59
58
  function registerGateway(accountId, gateway) {
60
59
  gatewayRegistry.set(resolveAccountKey(accountId), gateway);
61
60
  }
62
- /** Unregister a GatewayPlugin instance for an account. */
63
61
  function unregisterGateway(accountId) {
64
62
  gatewayRegistry.delete(resolveAccountKey(accountId));
65
63
  }
66
- /** Get the GatewayPlugin for an account. Returns undefined if not registered. */
67
64
  function getGateway(accountId) {
68
65
  return gatewayRegistry.get(resolveAccountKey(accountId));
69
66
  }
70
- /** Clear all registered gateways (for testing). */
71
67
  function clearGateways() {
72
68
  gatewayRegistry.clear();
73
69
  }
@@ -78,11 +74,8 @@ function resolveDiscordProxyUrl(account, cfg) {
78
74
  if (accountProxy) return accountProxy;
79
75
  return normalizeOptionalString(cfg?.channels?.discord?.proxy);
80
76
  }
81
- function resolveDiscordProxyFetchByUrl(proxyUrl, runtime) {
82
- return withValidatedDiscordProxy(proxyUrl, runtime, (proxy) => makeProxyFetch(proxy));
83
- }
84
77
  function resolveDiscordProxyFetchForAccount(account, cfg, runtime) {
85
- return resolveDiscordProxyFetchByUrl(resolveDiscordProxyUrl(account, cfg), runtime);
78
+ return withValidatedDiscordProxy(resolveDiscordProxyUrl(account, cfg), runtime, makeProxyFetch);
86
79
  }
87
80
  function withValidatedDiscordProxy(proxyUrl, runtime, createValue) {
88
81
  const proxy = proxyUrl?.trim();
@@ -112,7 +105,6 @@ const DISCORD_REST_TIMEOUT_MS = 15e3;
112
105
  function createDiscordRequestClient(token, options) {
113
106
  if (!options?.fetch) return new RequestClient(token, options);
114
107
  return new RequestClient(token, {
115
- runtimeProfile: "persistent",
116
108
  maxQueueSize: 1e3,
117
109
  timeout: DISCORD_REST_TIMEOUT_MS,
118
110
  ...options,
@@ -224,13 +216,9 @@ function resolveDiscordSendComponents(params) {
224
216
  if (!params.components || !params.isFirst) return;
225
217
  return typeof params.components === "function" ? params.components(params.text) : params.components;
226
218
  }
227
- function normalizeDiscordEmbeds(embeds) {
228
- if (!embeds?.length) return;
229
- return embeds.map((embed) => embed instanceof Embed ? embed : new Embed(embed));
230
- }
231
219
  function resolveDiscordSendEmbeds(params) {
232
- if (!params.embeds || !params.isFirst) return;
233
- return normalizeDiscordEmbeds(params.embeds);
220
+ if (!params.embeds?.length || !params.isFirst) return;
221
+ return params.embeds.map((embed) => embed instanceof Embed ? embed : new Embed(embed));
234
222
  }
235
223
  function buildDiscordMessagePayload(params) {
236
224
  const payload = {};
@@ -294,7 +282,7 @@ async function fetchBotUserId(rest) {
294
282
  return me.id;
295
283
  }
296
284
  function resolveMemberGuildPermissionBits(params) {
297
- const rolesByIdLocal = new Map((params.guild.roles ?? []).map((role) => [role.id, role]));
285
+ const rolesByIdLocal = rolesById(params.guild);
298
286
  const everyoneRole = rolesByIdLocal.get(params.guild.id);
299
287
  let permissions = 0n;
300
288
  if (everyoneRole?.permissions) permissions = addPermissionBits(permissions, everyoneRole.permissions);
@@ -736,8 +724,5 @@ function buildReactionIdentifier(emoji) {
736
724
  if (emoji.id && emoji.name) return `${emoji.name}:${emoji.id}`;
737
725
  return emoji.name ?? "";
738
726
  }
739
- function formatReactionEmoji(emoji) {
740
- return buildReactionIdentifier(emoji);
741
- }
742
727
  //#endregion
743
- export { resolveDiscordSendComponents as A, validateDiscordProxyUrl as B, hasAllGuildPermissionsDiscord as C, buildDiscordMessageRequest as D, SUPPRESS_NOTIFICATIONS_FLAG as E, createDiscordRuntimeAccountContext as F, unregisterGateway as G, clearGateways as H, resolveDiscordClientAccountContext as I, parseAndResolveChannelRecipient as K, resolveDiscordRest as L, resolveDiscordSuppressEmbeds as M, createDiscordClient as N, createDiscordMessageNonce as O, createDiscordRestClient as P, DISCORD_REST_TIMEOUT_MS as R, fetchMemberGuildPermissionsDiscord as S, hasAnyGuildPermissionDiscord as T, getGateway as U, withValidatedDiscordProxy as V, registerGateway as W, DiscordSendError as _, normalizeDiscordPollInput as a, canViewDiscordGuildChannel as b, normalizeStickerIds as c, resolveDiscordTargetChannelId as d, sendDiscordMedia as f, DISCORD_MAX_STICKER_BYTES as g, DISCORD_MAX_EVENT_COVER_BYTES as h, formatReactionEmoji as i, resolveDiscordSendEmbeds as j, resolveDiscordMessageFlags as k, resolveChannelId as l, DISCORD_MAX_EMOJI_BYTES as m, buildDiscordTextChunks as n, normalizeEmojiName as o, sendDiscordText as p, buildReactionIdentifier as r, normalizeReactionEmoji as s, buildDiscordSendError as t, resolveDiscordChannel as u, canManageGuildMemberRoleDiscord as v, hasAnyChannelPermissionDiscord as w, fetchChannelPermissionsDiscord as x, canManageGuildRoleDiscord as y, resolveDiscordProxyFetchForAccount as z };
728
+ export { resolveDiscordSendEmbeds as A, withValidatedDiscordProxy as B, hasAnyChannelPermissionDiscord as C, createDiscordMessageNonce as D, buildDiscordMessageRequest as E, resolveDiscordClientAccountContext as F, parseAndResolveChannelRecipient as G, getGateway as H, resolveDiscordRest as I, DISCORD_REST_TIMEOUT_MS as L, createDiscordClient as M, createDiscordRestClient as N, resolveDiscordMessageFlags as O, createDiscordRuntimeAccountContext as P, resolveDiscordProxyFetchForAccount as R, hasAllGuildPermissionsDiscord as S, SUPPRESS_NOTIFICATIONS_FLAG as T, registerGateway as U, clearGateways as V, unregisterGateway as W, canManageGuildMemberRoleDiscord as _, normalizeEmojiName as a, fetchChannelPermissionsDiscord as b, resolveChannelId as c, sendDiscordMedia as d, sendDiscordText as f, DiscordSendError as g, DISCORD_MAX_STICKER_BYTES as h, normalizeDiscordPollInput as i, resolveDiscordSuppressEmbeds as j, resolveDiscordSendComponents as k, resolveDiscordChannel as l, DISCORD_MAX_EVENT_COVER_BYTES as m, buildDiscordTextChunks as n, normalizeReactionEmoji as o, DISCORD_MAX_EMOJI_BYTES as p, buildReactionIdentifier as r, normalizeStickerIds as s, buildDiscordSendError as t, resolveDiscordTargetChannelId as u, canManageGuildRoleDiscord as v, hasAnyGuildPermissionDiscord as w, fetchMemberGuildPermissionsDiscord as x, canViewDiscordGuildChannel as y, validateDiscordProxyUrl as z };
@@ -1,9 +1,8 @@
1
- import { x as formatDiscordUserTag } from "./channel-type-DKnjV1XW.mjs";
1
+ import { S as formatDiscordUserTag } from "./channel-type-DRCrEMss.mjs";
2
2
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  //#region extensions/discord/src/monitor/sender-identity.ts
4
4
  function resolveDiscordWebhookId(message) {
5
- const candidate = message.webhookId ?? message.webhook_id;
6
- return typeof candidate === "string" && candidate.trim() ? candidate.trim() : null;
5
+ return normalizeOptionalString(message.webhookId ?? message.webhook_id) ?? null;
7
6
  }
8
7
  function resolveDiscordSenderIdentity(params) {
9
8
  const pkInfo = params.pluralkitInfo ?? null;
@@ -0,0 +1,3 @@
1
+ import { t as discordSetupPlugin } from "./channel.setup-CRo1GjV7.mjs";
2
+ import "../setup-plugin-api.js";
3
+ export { discordSetupPlugin };