@openclaw/discord 2026.10.10 → 2026.11.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{account-inspect-X_Xlr42B.mjs → account-inspect-CSz5Qodj.mjs} +1 -1
- package/dist/.setup/{accounts-C18HNgge.mjs → accounts-DtjvhJUj.mjs} +9 -6
- package/dist/.setup/{active-turn-thread-route-BAc_Xik-.mjs → active-turn-thread-route-DkPnk2x8.mjs} +1 -2
- package/dist/.setup/{allow-list-D1ZGfhXh.mjs → allow-list-DahA0Jxh.mjs} +3 -150
- package/dist/.setup/{api-Bth1wKF9.mjs → api-Bp0HI4q3.mjs} +10 -20
- package/dist/.setup/{approval-handler.runtime-BAoEELJJ.mjs → approval-handler.runtime-Cy53ugTf.mjs} +80 -61
- package/dist/.setup/{approval-message-updates-Cks-MSCJ.mjs → approval-message-updates-DqOXxPss.mjs} +2 -2
- package/dist/.setup/{audit-Dw_rAZIz.mjs → audit-DoPKOfQE.mjs} +4 -4
- package/dist/.setup/{channel-BMpMAeQL.mjs → channel-Ds6iuNdy.mjs} +134 -201
- package/dist/.setup/channel-access-DhJhVrdZ.mjs +23 -0
- package/dist/.setup/channel.setup-BLt9dkIG.mjs +235 -0
- package/dist/.setup/{components-BvOWSPxr.mjs → components-WTfUxead.mjs} +208 -426
- package/dist/.setup/components.base-C5sAPHe4.mjs +31 -0
- package/dist/.setup/{config-schema-Coyq5wOr.mjs → config-schema-GX2yDgIH.mjs} +6 -7
- package/dist/.setup/{conversation-binding-route-DOPUZNYo.mjs → conversation-binding-route-CZdm-X5A.mjs} +2 -2
- package/dist/.setup/{directory-config-CIqVnQtn.mjs → directory-config-BXJuh9-J.mjs} +1 -1
- package/dist/.setup/{directory-live-DUuPEWub.mjs → directory-live-CEopeb8Q.mjs} +55 -62
- package/dist/.setup/{discord-eFlHX1Gn.mjs → discord-r79VFjJp.mjs} +1087 -1664
- package/dist/.setup/{doctor-Dty_Ossy.mjs → doctor-UfLW8nye.mjs} +3 -5
- package/dist/.setup/endpoint-runtime-BM3x-m6O.mjs +138 -0
- package/dist/.setup/guilds-DQucP5Tn.mjs +21 -0
- package/dist/.setup/{handle-action-DXY91jF-.mjs → handle-action-BarHOi-v.mjs} +15 -15
- package/dist/.setup/{handle-action.guild-admin-BvBCfhXF.mjs → handle-action.guild-admin-oRUb8p_O.mjs} +5 -5
- package/dist/.setup/listeners-CHgTENFu.mjs +46 -0
- package/dist/.setup/{live-policy-config-DO1Fk2hp.mjs → live-policy-config-EKp4O6zx.mjs} +2 -3
- package/dist/.setup/{message-handler-fL1j1NiR.mjs → message-handler-DUeT8Asf.mjs} +154 -113
- package/dist/.setup/{message-handler.preflight-DkjwNZAd.mjs → message-handler.preflight-C6TNtKW0.mjs} +30 -104
- package/dist/.setup/{message-handler.preflight-pluralkit-DR4BnvMU.mjs → message-handler.preflight-pluralkit-6E9TFmmN.mjs} +9 -22
- package/dist/.setup/{message-handler.process-ClOwIPDK.mjs → message-handler.process-D8_oQ5Cp.mjs} +256 -367
- package/dist/.setup/outbound-payload-DUsrFICb.mjs +445 -0
- package/dist/.setup/{outbound-session-route-TFBPPkoz.mjs → outbound-session-route-Cb8cv4Oi.mjs} +138 -86
- package/dist/.setup/{preflight-audio-CwtPIsvk.mjs → preflight-audio-r4BbaJxh.mjs} +1 -5
- package/dist/.setup/{presence-cache-CgutE4NN.mjs → presence-cache-B3xj3b0l.mjs} +1 -6
- package/dist/.setup/{probe-DNge7OEP.mjs → probe-BUmJyH35.mjs} +5 -9
- package/dist/.setup/{provider-BBDuE14w.mjs → provider-Dm2ERSxe.mjs} +3600 -4454
- package/dist/.setup/{provider-session.runtime-D8hMXXqJ.mjs → provider-session.runtime-DCIqDsIg.mjs} +3 -3
- package/dist/.setup/provider.runtime-DmxPGoUg.mjs +1 -0
- package/dist/.setup/proxy-fetch-B8cK6FLQ.mjs +29 -0
- package/dist/.setup/{realtime-session.runtime-cetognkp.mjs → realtime-session.runtime-WJL6NdwK.mjs} +43 -81
- package/dist/.setup/{receive-recovery-C77CVdGM.mjs → receive-recovery-DV_v5ROf.mjs} +13 -27
- package/dist/.setup/{resolve-allowlist-common-CI77288n.mjs → resolve-allowlist-common-C37fgnYG.mjs} +3 -12
- package/dist/.setup/{resolve-channels-DYc6-xgV.mjs → resolve-channels-CwpnQ7C2.mjs} +5 -4
- package/dist/.setup/{resolve-users-BQT7XWF2.mjs → resolve-users-D6jSwe8R.mjs} +4 -7
- package/dist/.setup/{runtime-CcijhTJT.mjs → runtime-B-PgPsGR.mjs} +6 -6
- package/dist/.setup/{runtime-CI0UJqeS.mjs → runtime-DhOMlnYS.mjs} +196 -235
- package/dist/.setup/{secret-config-contract-BdbCvqnM.mjs → secret-config-contract-CP6teHec.mjs} +4 -9
- package/dist/.setup/{send-Cbq-IVsS.mjs → send-DnLL6XoO.mjs} +149 -174
- package/dist/.setup/{send.components-BV6ucNpJ.mjs → send.components-xB43CksK.mjs} +61 -71
- package/dist/.setup/{send.outbound-CGhBhzjQ.mjs → send.outbound-B11X6TOE.mjs} +75 -129
- package/dist/.setup/{send.receipt-Dw-_r5Bx.mjs → send.receipt-CMteCIZS.mjs} +29 -31
- package/dist/.setup/{send.shared-D4MioxW_.mjs → send.shared-BcLLZBul.mjs} +38 -112
- package/dist/.setup/{sender-identity-DrN5c4ec.mjs → sender-identity-CGNpdJmb.mjs} +3 -9
- package/dist/.setup/setup-plugin-api-C6AMx3hu.mjs +2 -0
- package/dist/.setup/{shared-Bp0sxD5R.mjs → shared-BEYw16he.mjs} +8 -10
- package/dist/.setup/shared-interactive-DKBw4SNV.mjs +311 -0
- package/dist/.setup/{subagent-hooks-mQbDkvuD.mjs → subagent-hooks-DlYElpXa.mjs} +1 -1
- package/dist/.setup/{system-events-2zc2eGfF.mjs → system-events--Pk6y9aP.mjs} +2 -2
- package/dist/.setup/{target-resolver-CAHeVfmZ.mjs → target-resolver-Bo9EpGp_.mjs} +3 -3
- package/dist/.setup/{thread-bindings-Dg7X_ZXP.mjs → thread-bindings-BF-hr-bg.mjs} +12 -20
- package/dist/.setup/{thread-bindings.manager-DCDYksah.mjs → thread-bindings.manager-CQCkha5r.mjs} +22 -42
- package/dist/.setup/{thread-bindings.session-updates-C76plLS3.mjs → thread-bindings.session-updates-C2gJAj_I.mjs} +11 -18
- package/dist/.setup/{threading-l0UfrE6x.mjs → threading-HA9C2wYR.mjs} +68 -104
- package/dist/.setup/{timeouts-DTrUsJ_W.mjs → timeouts-CT9hnmo4.mjs} +1 -1
- package/dist/.setup/{transcripts-source-CGgOaWcu.mjs → transcripts-source-DzpzETZR.mjs} +102 -172
- package/dist/.setup/{voice-runtime-DY1EwDfi.mjs → voice-runtime-Bo_nsVvX.mjs} +231 -448
- package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +285 -337
- package/dist/api.js +16 -16
- package/dist/assets/embedded-app-sdk.mjs +1 -1
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/runtime-api.js +22 -22
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/src/voice/audio-worker.runtime.js +56 -68
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.cjs +2 -3
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.mjs +2 -3
- package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
- package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
- package/node_modules/@types/lodash/README.md +1 -1
- package/node_modules/@types/lodash/common/function.d.ts +2 -2
- package/node_modules/@types/lodash/package.json +2 -2
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/util.d.ts +6 -3
- package/node_modules/discord-api-types/package.json +4 -4
- package/node_modules/discord-api-types/rest/v10/index.d.ts +8 -0
- package/node_modules/discord-api-types/rest/v10/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v10/index.js +8 -0
- package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/oauth2.d.ts +26 -2
- package/node_modules/discord-api-types/rest/v10/oauth2.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/index.d.ts +8 -0
- package/node_modules/discord-api-types/rest/v9/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/index.js +8 -0
- package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v9/oauth2.d.ts +26 -2
- package/node_modules/discord-api-types/rest/v9/oauth2.d.ts.map +1 -1
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
- package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
- package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
- package/node_modules/undici/package.json +3 -3
- package/node_modules/undici/types/api.d.ts +1 -1
- package/node_modules/undici/types/utility.d.ts +4 -4
- package/node_modules/uuid/package.json +17 -17
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +1 -31
- package/package.json +8 -8
- package/dist/.setup/channel-access-BPrWoEXM.mjs +0 -47
- package/dist/.setup/channel.setup-DVe7Y3Jf.mjs +0 -245
- package/dist/.setup/outbound-adapter-DWyAWBFh.mjs +0 -537
- package/dist/.setup/provider.runtime-BQ1z4Aq1.mjs +0 -1
- package/dist/.setup/setup-plugin-api-B4J6wmL1.mjs +0 -2
- package/dist/.setup/targets-BaklhOqq.mjs +0 -3
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -1,121 +1,18 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { J as stripUndefinedFields, a as Label, c as TextInput, i as CheckboxGroup, o as Modal, s as RadioGroup, u as asSerializableComponent } from "./discord-r79VFjJp.mjs";
|
|
3
|
+
import { i as parseCustomId, r as colorToNumber, t as BaseMessageInteractiveComponent } from "./components.base-C5sAPHe4.mjs";
|
|
4
|
+
import { _ as parseDiscordModalCustomId, c as DISCORD_COMPONENT_CUSTOM_ID_KEY, d as buildDiscordComponentCustomId, f as buildDiscordModalCustomId, g as parseDiscordComponentCustomIdForInteraction, h as parseDiscordComponentCustomId, l as DISCORD_MODAL_CUSTOM_ID_KEY, t as buildDiscordInteractiveComponents, v as parseDiscordModalCustomIdForInteraction } from "./shared-interactive-DKBw4SNV.mjs";
|
|
3
5
|
import { asBoolean, asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, readNonBlankString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
-
import { ButtonStyle, MessageFlags, TextInputStyle } from "discord-api-types/v10";
|
|
5
|
-
import { resolveAskUserQuestionOptionIndex } from "openclaw/plugin-sdk/reply-payload";
|
|
6
|
+
import { ButtonStyle, ComponentType, MessageFlags, TextInputStyle } from "discord-api-types/v10";
|
|
6
7
|
import crypto from "node:crypto";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
const encodeCustomIdComponent = encodeURIComponent;
|
|
17
|
-
function decodeCustomIdComponent(value) {
|
|
18
|
-
try {
|
|
19
|
-
return decodeURIComponent(value);
|
|
20
|
-
} catch {
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Minimal field escape for the versioned `occomp`/`ocmodal` grammar: only `%`
|
|
26
|
-
* and the `;` field separator are escaped to preserve the 100-char custom-id
|
|
27
|
-
* budget. The wire format is versioned (`e=1`); do not swap this for the URI
|
|
28
|
-
* codec — in-flight component ids must keep decoding byte-exactly.
|
|
29
|
-
*/
|
|
30
|
-
function escapeCustomIdFieldValue(value) {
|
|
31
|
-
return value.replace(/%/g, "%25").replace(/;/g, "%3B");
|
|
32
|
-
}
|
|
33
|
-
function needsCustomIdFieldEscaping(value) {
|
|
34
|
-
return /[%;]/.test(value);
|
|
35
|
-
}
|
|
36
|
-
function unescapeCustomIdFieldValue(value) {
|
|
37
|
-
return value.replace(/%(25|3B)/gi, (match) => match.toLowerCase() === "%25" ? "%" : ";");
|
|
38
|
-
}
|
|
39
|
-
// extensions/discord/src/component-custom-id.ts
|
|
40
|
-
const DISCORD_COMPONENT_CUSTOM_ID_KEY = "occomp";
|
|
41
|
-
const DISCORD_MODAL_CUSTOM_ID_KEY = "ocmodal";
|
|
42
|
-
const DISCORD_ACTIVITY_CUSTOM_ID_KEY = "ocactivity";
|
|
43
|
-
const ENCODED_CUSTOM_ID_VERSION = "1";
|
|
44
|
-
const DISCORD_ACTIVITY_CUSTOM_ID_PREFIX = `${DISCORD_ACTIVITY_CUSTOM_ID_KEY}${ENCODED_CUSTOM_ID_VERSION}_`;
|
|
45
|
-
function isValidDiscordActivityWidgetId(widgetId) {
|
|
46
|
-
return /^[A-Za-z0-9_-]{22}$/.test(widgetId);
|
|
47
|
-
}
|
|
48
|
-
function buildDiscordActivityCustomId(widgetId) {
|
|
49
|
-
return `${DISCORD_ACTIVITY_CUSTOM_ID_PREFIX}${widgetId}`;
|
|
50
|
-
}
|
|
51
|
-
function parseDiscordActivityCustomId(id) {
|
|
52
|
-
if (id.startsWith(DISCORD_ACTIVITY_CUSTOM_ID_PREFIX)) {
|
|
53
|
-
const widgetId = id.slice(DISCORD_ACTIVITY_CUSTOM_ID_PREFIX.length);
|
|
54
|
-
return isValidDiscordActivityWidgetId(widgetId) ? { widgetId } : null;
|
|
55
|
-
}
|
|
56
|
-
const parsed = parseCustomId(id);
|
|
57
|
-
if (parsed.key !== DISCORD_ACTIVITY_CUSTOM_ID_KEY || parsed.data.v !== ENCODED_CUSTOM_ID_VERSION || typeof parsed.data.wid !== "string" || !isValidDiscordActivityWidgetId(parsed.data.wid)) return null;
|
|
58
|
-
return { widgetId: parsed.data.wid };
|
|
59
|
-
}
|
|
60
|
-
function parseDiscordActivityCustomIdForInteraction(id) {
|
|
61
|
-
const parsed = parseDiscordActivityCustomId(id);
|
|
62
|
-
return parsed ? {
|
|
63
|
-
key: DISCORD_ACTIVITY_CUSTOM_ID_KEY,
|
|
64
|
-
data: { widgetId: parsed.widgetId }
|
|
65
|
-
} : parseCustomId(id);
|
|
66
|
-
}
|
|
67
|
-
function decodeParsedCustomIdData(data) {
|
|
68
|
-
if (data.e !== ENCODED_CUSTOM_ID_VERSION) return data;
|
|
69
|
-
return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, typeof value === "string" ? unescapeCustomIdFieldValue(value) : value]));
|
|
70
|
-
}
|
|
71
|
-
function buildDiscordFieldCustomId(key, fields) {
|
|
72
|
-
const encoded = Object.values(fields).some(needsCustomIdFieldEscaping);
|
|
73
|
-
const parts = Object.entries(fields).map(([name, value]) => `${name}=${encoded ? escapeCustomIdFieldValue(value) : value}`);
|
|
74
|
-
return (encoded ? `${key}:e=${ENCODED_CUSTOM_ID_VERSION};` : `${key}:`) + parts.join(";");
|
|
75
|
-
}
|
|
76
|
-
function buildDiscordComponentCustomId(params) {
|
|
77
|
-
return buildDiscordFieldCustomId(DISCORD_COMPONENT_CUSTOM_ID_KEY, {
|
|
78
|
-
cid: params.componentId,
|
|
79
|
-
...params.modalId ? { mid: params.modalId } : {}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
function buildDiscordModalCustomId(modalId) {
|
|
83
|
-
return buildDiscordFieldCustomId(DISCORD_MODAL_CUSTOM_ID_KEY, { mid: modalId });
|
|
84
|
-
}
|
|
85
|
-
function parseDiscordComponentCustomId(id) {
|
|
86
|
-
const parsed = parseCustomId(id);
|
|
87
|
-
if (parsed.key !== "occomp") return null;
|
|
88
|
-
const data = decodeParsedCustomIdData(parsed.data);
|
|
89
|
-
const componentId = readNonBlankString(data.cid);
|
|
90
|
-
if (!componentId) return null;
|
|
91
|
-
return {
|
|
92
|
-
componentId,
|
|
93
|
-
modalId: readNonBlankString(data.mid)
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function parseDiscordModalCustomId(id) {
|
|
97
|
-
const parsed = parseCustomId(id);
|
|
98
|
-
if (parsed.key !== "ocmodal") return null;
|
|
99
|
-
return readNonBlankString(decodeParsedCustomIdData(parsed.data).mid) ?? null;
|
|
100
|
-
}
|
|
101
|
-
function parseDiscordCustomIdForInteraction(id, key) {
|
|
102
|
-
if (id === "*" || /^__openclaw_discord_component_[a-z_]+_wildcard__$/.test(id)) return {
|
|
103
|
-
key: "*",
|
|
104
|
-
data: {}
|
|
105
|
-
};
|
|
106
|
-
const parsed = parseCustomId(id);
|
|
107
|
-
if (parsed.key !== key) return parsed;
|
|
108
|
-
return {
|
|
109
|
-
key: "*",
|
|
110
|
-
data: decodeParsedCustomIdData(parsed.data)
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function parseDiscordComponentCustomIdForInteraction(id) {
|
|
114
|
-
return parseDiscordCustomIdForInteraction(id, DISCORD_COMPONENT_CUSTOM_ID_KEY);
|
|
115
|
-
}
|
|
116
|
-
function parseDiscordModalCustomIdForInteraction(id) {
|
|
117
|
-
return parseDiscordCustomIdForInteraction(id, DISCORD_MODAL_CUSTOM_ID_KEY);
|
|
118
|
-
}
|
|
8
|
+
// extensions/discord/src/components.types.ts
|
|
9
|
+
const DISCORD_COMPONENT_SELECT_TYPES = [
|
|
10
|
+
"string",
|
|
11
|
+
"user",
|
|
12
|
+
"role",
|
|
13
|
+
"mentionable",
|
|
14
|
+
"channel"
|
|
15
|
+
];
|
|
119
16
|
// extensions/discord/src/components.parse.ts
|
|
120
17
|
const DISCORD_COMPONENT_ATTACHMENT_PREFIX = "attachment://";
|
|
121
18
|
const BLOCK_ALIASES = /* @__PURE__ */ new Map([["row", "actions"], ["action-row", "actions"]]);
|
|
@@ -227,13 +124,7 @@ function parseButtonSpec(raw, label) {
|
|
|
227
124
|
function parseSelectSpec(raw, label) {
|
|
228
125
|
const obj = requireObject(raw, label);
|
|
229
126
|
return {
|
|
230
|
-
type: readOptionalEnum(obj.type, `${label}.type`,
|
|
231
|
-
"string",
|
|
232
|
-
"user",
|
|
233
|
-
"role",
|
|
234
|
-
"mentionable",
|
|
235
|
-
"channel"
|
|
236
|
-
]),
|
|
127
|
+
type: readOptionalEnum(obj.type, `${label}.type`, DISCORD_COMPONENT_SELECT_TYPES),
|
|
237
128
|
callbackData: normalizeOptionalString(obj.callbackData),
|
|
238
129
|
callbackDataKind: readCallbackDataKind(obj.callbackDataKind, `${label}.callbackDataKind`),
|
|
239
130
|
placeholder: normalizeOptionalString(obj.placeholder),
|
|
@@ -419,82 +310,35 @@ function readDiscordComponentSpec(raw) {
|
|
|
419
310
|
function createShortId(prefix) {
|
|
420
311
|
return `${prefix}${crypto.randomBytes(6).toString("base64url")}`;
|
|
421
312
|
}
|
|
422
|
-
const selectMenuConstructors = {
|
|
423
|
-
string: class extends StringSelectMenu {
|
|
424
|
-
constructor(..._args) {
|
|
425
|
-
super(..._args);
|
|
426
|
-
this.customId = "";
|
|
427
|
-
this.options = [];
|
|
428
|
-
}
|
|
429
|
-
},
|
|
430
|
-
user: class extends UserSelectMenu {
|
|
431
|
-
constructor(..._args2) {
|
|
432
|
-
super(..._args2);
|
|
433
|
-
this.customId = "";
|
|
434
|
-
}
|
|
435
|
-
},
|
|
436
|
-
role: class extends RoleSelectMenu {
|
|
437
|
-
constructor(..._args3) {
|
|
438
|
-
super(..._args3);
|
|
439
|
-
this.customId = "";
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
mentionable: class extends MentionableSelectMenu {
|
|
443
|
-
constructor(..._args4) {
|
|
444
|
-
super(..._args4);
|
|
445
|
-
this.customId = "";
|
|
446
|
-
}
|
|
447
|
-
},
|
|
448
|
-
channel: class extends ChannelSelectMenu {
|
|
449
|
-
constructor(..._args5) {
|
|
450
|
-
super(..._args5);
|
|
451
|
-
this.customId = "";
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
function createDiscordSelectMenu(type, customId, options) {
|
|
456
|
-
const SelectMenu = selectMenuConstructors[type];
|
|
457
|
-
const select = new SelectMenu();
|
|
458
|
-
select.customId = customId;
|
|
459
|
-
if (select instanceof StringSelectMenu) select.options = options ?? [];
|
|
460
|
-
return select;
|
|
461
|
-
}
|
|
462
313
|
function createButtonComponent(params) {
|
|
463
314
|
const style = mapButtonStyle(params.spec.style);
|
|
464
|
-
if (style === ButtonStyle.Link ||
|
|
315
|
+
if (style === ButtonStyle.Link || params.spec.url) {
|
|
465
316
|
if (!params.spec.url) throw new Error("Link buttons require a url");
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return { component: new DynamicLinkButton() };
|
|
317
|
+
return { component: stripUndefinedFields({
|
|
318
|
+
type: ComponentType.Button,
|
|
319
|
+
style: ButtonStyle.Link,
|
|
320
|
+
label: params.spec.label,
|
|
321
|
+
url: params.spec.url,
|
|
322
|
+
emoji: params.spec.emoji,
|
|
323
|
+
disabled: params.spec.disabled || void 0
|
|
324
|
+
}) };
|
|
477
325
|
}
|
|
478
326
|
const componentId = createShortId("btn_");
|
|
479
|
-
const internalCustomId =
|
|
327
|
+
const internalCustomId = params.spec.internalCustomId?.trim() || void 0;
|
|
480
328
|
const customId = internalCustomId ?? buildDiscordComponentCustomId({
|
|
481
329
|
componentId,
|
|
482
330
|
modalId: params.modalId
|
|
483
331
|
});
|
|
484
|
-
class DynamicButton extends Button {
|
|
485
|
-
constructor(..._args7) {
|
|
486
|
-
super(..._args7);
|
|
487
|
-
this.label = params.spec.label;
|
|
488
|
-
this.customId = customId;
|
|
489
|
-
this.style = style;
|
|
490
|
-
this.emoji = params.spec.emoji;
|
|
491
|
-
this.disabled = params.spec.disabled ?? false;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
if (internalCustomId) return { component: new DynamicButton() };
|
|
495
332
|
return {
|
|
496
|
-
component:
|
|
497
|
-
|
|
333
|
+
component: stripUndefinedFields({
|
|
334
|
+
type: ComponentType.Button,
|
|
335
|
+
style,
|
|
336
|
+
label: params.spec.label,
|
|
337
|
+
custom_id: customId,
|
|
338
|
+
emoji: params.spec.emoji,
|
|
339
|
+
disabled: params.spec.disabled || void 0
|
|
340
|
+
}),
|
|
341
|
+
entry: internalCustomId ? void 0 : stripUndefinedFields({
|
|
498
342
|
id: componentId,
|
|
499
343
|
kind: params.modalId ? "modal-trigger" : "button",
|
|
500
344
|
label: params.spec.label,
|
|
@@ -506,39 +350,6 @@ function createButtonComponent(params) {
|
|
|
506
350
|
})
|
|
507
351
|
};
|
|
508
352
|
}
|
|
509
|
-
function createSelectComponent(params) {
|
|
510
|
-
const type = normalizeLowercaseStringOrEmpty(params.spec.type ?? "string");
|
|
511
|
-
const componentId = createShortId("sel_");
|
|
512
|
-
const customId = buildDiscordComponentCustomId({ componentId });
|
|
513
|
-
const options = params.spec.options ?? [];
|
|
514
|
-
if (type === "string" && options.length === 0) throw new Error("String select menus require options");
|
|
515
|
-
const select = createDiscordSelectMenu(type, customId, options);
|
|
516
|
-
select.minValues = params.spec.minValues;
|
|
517
|
-
select.maxValues = params.spec.maxValues;
|
|
518
|
-
select.placeholder = params.spec.placeholder;
|
|
519
|
-
return {
|
|
520
|
-
component: select,
|
|
521
|
-
entry: stripUndefinedFields({
|
|
522
|
-
id: componentId,
|
|
523
|
-
kind: "select",
|
|
524
|
-
label: params.spec.placeholder ?? {
|
|
525
|
-
string: "select",
|
|
526
|
-
user: "user select",
|
|
527
|
-
role: "role select",
|
|
528
|
-
mentionable: "mentionable select",
|
|
529
|
-
channel: "channel select"
|
|
530
|
-
}[type],
|
|
531
|
-
callbackData: params.spec.callbackData,
|
|
532
|
-
callbackDataKind: params.spec.callbackDataKind,
|
|
533
|
-
selectType: type,
|
|
534
|
-
options: type === "string" ? options.map((option) => ({
|
|
535
|
-
value: option.value,
|
|
536
|
-
label: option.label
|
|
537
|
-
})) : void 0,
|
|
538
|
-
allowedUsers: params.spec.allowedUsers
|
|
539
|
-
})
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
353
|
function buildDiscordComponentMessage(params) {
|
|
543
354
|
const entries = [];
|
|
544
355
|
const consumptionGroupId = createShortId("grp_");
|
|
@@ -562,34 +373,62 @@ function buildDiscordComponentMessage(params) {
|
|
|
562
373
|
return component;
|
|
563
374
|
};
|
|
564
375
|
const text = params.spec.text ?? params.fallbackText;
|
|
565
|
-
if (text) containerChildren.push(
|
|
376
|
+
if (text) containerChildren.push({
|
|
377
|
+
type: ComponentType.TextDisplay,
|
|
378
|
+
content: text
|
|
379
|
+
});
|
|
566
380
|
for (const block of params.spec.blocks ?? []) {
|
|
567
381
|
if (block.type === "text") {
|
|
568
|
-
containerChildren.push(
|
|
382
|
+
containerChildren.push({
|
|
383
|
+
type: ComponentType.TextDisplay,
|
|
384
|
+
content: block.text
|
|
385
|
+
});
|
|
569
386
|
continue;
|
|
570
387
|
}
|
|
571
388
|
if (block.type === "section") {
|
|
572
|
-
const displays = (block.texts?.length ? block.texts : block.text ? [block.text] : []).map((
|
|
389
|
+
const displays = (block.texts?.length ? block.texts : block.text ? [block.text] : []).map((content) => ({
|
|
390
|
+
type: ComponentType.TextDisplay,
|
|
391
|
+
content
|
|
392
|
+
}));
|
|
573
393
|
if (displays.length > 3) throw new Error("Section blocks support up to 3 text displays");
|
|
574
394
|
let accessory;
|
|
575
|
-
if (block.accessory?.type === "thumbnail") accessory =
|
|
395
|
+
if (block.accessory?.type === "thumbnail") accessory = {
|
|
396
|
+
type: ComponentType.Thumbnail,
|
|
397
|
+
media: { url: block.accessory.url }
|
|
398
|
+
};
|
|
576
399
|
else if (block.accessory?.type === "button") accessory = buildButton({ spec: block.accessory.button });
|
|
577
|
-
containerChildren.push(
|
|
400
|
+
containerChildren.push(stripUndefinedFields({
|
|
401
|
+
type: ComponentType.Section,
|
|
402
|
+
components: displays,
|
|
403
|
+
accessory
|
|
404
|
+
}));
|
|
578
405
|
continue;
|
|
579
406
|
}
|
|
580
407
|
if (block.type === "separator") {
|
|
581
|
-
containerChildren.push(
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
408
|
+
containerChildren.push({
|
|
409
|
+
type: ComponentType.Separator,
|
|
410
|
+
spacing: block.spacing === "large" || block.spacing === 2 ? 2 : 1,
|
|
411
|
+
divider: block.divider ?? true
|
|
412
|
+
});
|
|
585
413
|
continue;
|
|
586
414
|
}
|
|
587
415
|
if (block.type === "media-gallery") {
|
|
588
|
-
containerChildren.push(
|
|
416
|
+
containerChildren.push({
|
|
417
|
+
type: ComponentType.MediaGallery,
|
|
418
|
+
items: block.items.map(({ url, description, spoiler }) => ({
|
|
419
|
+
media: { url },
|
|
420
|
+
description,
|
|
421
|
+
spoiler
|
|
422
|
+
}))
|
|
423
|
+
});
|
|
589
424
|
continue;
|
|
590
425
|
}
|
|
591
426
|
if (block.type === "file") {
|
|
592
|
-
containerChildren.push(
|
|
427
|
+
containerChildren.push(stripUndefinedFields({
|
|
428
|
+
type: ComponentType.File,
|
|
429
|
+
file: { url: block.file },
|
|
430
|
+
spoiler: block.spoiler || void 0
|
|
431
|
+
}));
|
|
593
432
|
continue;
|
|
594
433
|
}
|
|
595
434
|
if (block.type === "actions") {
|
|
@@ -598,11 +437,57 @@ function buildDiscordComponentMessage(params) {
|
|
|
598
437
|
if (block.buttons.length > 5) throw new Error("Action rows support up to 5 buttons");
|
|
599
438
|
for (const button of block.buttons) buildButton({ spec: button }, rowComponents);
|
|
600
439
|
} else if (block.select) {
|
|
601
|
-
const
|
|
602
|
-
|
|
440
|
+
const selectSpec = block.select;
|
|
441
|
+
const type = selectSpec.type ?? "string";
|
|
442
|
+
const componentId = createShortId("sel_");
|
|
443
|
+
const customId = buildDiscordComponentCustomId({ componentId });
|
|
444
|
+
const options = selectSpec.options ?? [];
|
|
445
|
+
if (type === "string" && options.length === 0) throw new Error("String select menus require options");
|
|
446
|
+
const fields = stripUndefinedFields({
|
|
447
|
+
custom_id: customId,
|
|
448
|
+
min_values: selectSpec.minValues,
|
|
449
|
+
max_values: selectSpec.maxValues,
|
|
450
|
+
placeholder: selectSpec.placeholder
|
|
451
|
+
});
|
|
452
|
+
const select = type === "string" ? {
|
|
453
|
+
...fields,
|
|
454
|
+
type: ComponentType.StringSelect,
|
|
455
|
+
options
|
|
456
|
+
} : {
|
|
457
|
+
...fields,
|
|
458
|
+
type: {
|
|
459
|
+
user: ComponentType.UserSelect,
|
|
460
|
+
role: ComponentType.RoleSelect,
|
|
461
|
+
mentionable: ComponentType.MentionableSelect,
|
|
462
|
+
channel: ComponentType.ChannelSelect
|
|
463
|
+
}[type]
|
|
464
|
+
};
|
|
465
|
+
const entry = stripUndefinedFields({
|
|
466
|
+
id: componentId,
|
|
467
|
+
kind: "select",
|
|
468
|
+
label: selectSpec.placeholder ?? {
|
|
469
|
+
string: "select",
|
|
470
|
+
user: "user select",
|
|
471
|
+
role: "role select",
|
|
472
|
+
mentionable: "mentionable select",
|
|
473
|
+
channel: "channel select"
|
|
474
|
+
}[type],
|
|
475
|
+
callbackData: selectSpec.callbackData,
|
|
476
|
+
callbackDataKind: selectSpec.callbackDataKind,
|
|
477
|
+
selectType: type,
|
|
478
|
+
options: type === "string" ? options.map((option) => ({
|
|
479
|
+
value: option.value,
|
|
480
|
+
label: option.label
|
|
481
|
+
})) : void 0,
|
|
482
|
+
allowedUsers: selectSpec.allowedUsers
|
|
483
|
+
});
|
|
484
|
+
rowComponents.push(select);
|
|
603
485
|
addEntry(entry);
|
|
604
486
|
}
|
|
605
|
-
containerChildren.push(
|
|
487
|
+
containerChildren.push({
|
|
488
|
+
type: ComponentType.ActionRow,
|
|
489
|
+
components: rowComponents
|
|
490
|
+
});
|
|
606
491
|
}
|
|
607
492
|
}
|
|
608
493
|
if (params.spec.modal) {
|
|
@@ -642,11 +527,19 @@ function buildDiscordComponentMessage(params) {
|
|
|
642
527
|
modalId
|
|
643
528
|
});
|
|
644
529
|
const lastChild = containerChildren.at(-1);
|
|
645
|
-
if (lastChild
|
|
646
|
-
else containerChildren.push(
|
|
530
|
+
if (lastChild?.type === ComponentType.ActionRow && lastChild.components.length < 5 && lastChild.components.every((child) => child.type === ComponentType.Button)) lastChild.components.push(component);
|
|
531
|
+
else containerChildren.push({
|
|
532
|
+
type: ComponentType.ActionRow,
|
|
533
|
+
components: [component]
|
|
534
|
+
});
|
|
647
535
|
}
|
|
648
536
|
if (containerChildren.length === 0) throw new Error("components must include at least one block, text, or modal trigger");
|
|
649
|
-
const container =
|
|
537
|
+
const container = asSerializableComponent(stripUndefinedFields({
|
|
538
|
+
type: ComponentType.Container,
|
|
539
|
+
components: containerChildren,
|
|
540
|
+
accent_color: colorToNumber(params.spec.container?.accentColor),
|
|
541
|
+
spoiler: params.spec.container?.spoiler || void 0
|
|
542
|
+
}));
|
|
650
543
|
const consumptionGroupEntryIds = entries.map((entry) => entry.id);
|
|
651
544
|
for (const entry of entries) entry.consumptionGroupEntryIds = consumptionGroupEntryIds;
|
|
652
545
|
return {
|
|
@@ -658,6 +551,59 @@ function buildDiscordComponentMessage(params) {
|
|
|
658
551
|
function buildDiscordComponentMessageFlags(components) {
|
|
659
552
|
return components.some((component) => component.isV2) ? MessageFlags.IsComponentsV2 : void 0;
|
|
660
553
|
}
|
|
554
|
+
// extensions/discord/src/internal/components.message.ts
|
|
555
|
+
var AnySelectMenu = class extends BaseMessageInteractiveComponent {
|
|
556
|
+
constructor(..._args) {
|
|
557
|
+
super(..._args);
|
|
558
|
+
this.isV2 = false;
|
|
559
|
+
this.defer = false;
|
|
560
|
+
this.ephemeral = false;
|
|
561
|
+
this.customIdParser = parseCustomId;
|
|
562
|
+
this.disabled = false;
|
|
563
|
+
}
|
|
564
|
+
run(_interaction, _data) {}
|
|
565
|
+
serializeOptions() {
|
|
566
|
+
return {
|
|
567
|
+
type: this.type,
|
|
568
|
+
default_values: this.defaultValues
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
serialize() {
|
|
572
|
+
return stripUndefinedFields({
|
|
573
|
+
...this.serializeOptions(),
|
|
574
|
+
custom_id: this.customId,
|
|
575
|
+
placeholder: this.placeholder,
|
|
576
|
+
min_values: this.minValues,
|
|
577
|
+
max_values: this.maxValues,
|
|
578
|
+
disabled: this.disabled || void 0,
|
|
579
|
+
required: this.required
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
var StringSelectMenu = class extends AnySelectMenu {
|
|
584
|
+
constructor(..._args2) {
|
|
585
|
+
super(..._args2);
|
|
586
|
+
this.type = ComponentType.StringSelect;
|
|
587
|
+
}
|
|
588
|
+
serializeOptions() {
|
|
589
|
+
return {
|
|
590
|
+
type: this.type,
|
|
591
|
+
options: this.options
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
var UserSelectMenu = class extends AnySelectMenu {
|
|
596
|
+
constructor(..._args3) {
|
|
597
|
+
super(..._args3);
|
|
598
|
+
this.type = ComponentType.UserSelect;
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
var RoleSelectMenu = class extends AnySelectMenu {
|
|
602
|
+
constructor(..._args4) {
|
|
603
|
+
super(..._args4);
|
|
604
|
+
this.type = ComponentType.RoleSelect;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
661
607
|
// extensions/discord/src/components.modal.ts
|
|
662
608
|
function createModalFieldComponent(field) {
|
|
663
609
|
if (field.type === "text") {
|
|
@@ -675,7 +621,23 @@ function createModalFieldComponent(field) {
|
|
|
675
621
|
return new DynamicTextInput();
|
|
676
622
|
}
|
|
677
623
|
if (field.type === "select" || field.type === "role-select" || field.type === "user-select") {
|
|
678
|
-
const select =
|
|
624
|
+
const select = field.type === "select" ? new class extends StringSelectMenu {
|
|
625
|
+
constructor(..._args2) {
|
|
626
|
+
super(..._args2);
|
|
627
|
+
this.customId = field.id;
|
|
628
|
+
this.options = field.options ?? [];
|
|
629
|
+
}
|
|
630
|
+
}() : field.type === "role-select" ? new class extends RoleSelectMenu {
|
|
631
|
+
constructor(..._args3) {
|
|
632
|
+
super(..._args3);
|
|
633
|
+
this.customId = field.id;
|
|
634
|
+
}
|
|
635
|
+
}() : new class extends UserSelectMenu {
|
|
636
|
+
constructor(..._args4) {
|
|
637
|
+
super(..._args4);
|
|
638
|
+
this.customId = field.id;
|
|
639
|
+
}
|
|
640
|
+
}();
|
|
679
641
|
select.required = field.required;
|
|
680
642
|
select.minValues = field.minValues;
|
|
681
643
|
select.maxValues = field.maxValues;
|
|
@@ -683,13 +645,13 @@ function createModalFieldComponent(field) {
|
|
|
683
645
|
return select;
|
|
684
646
|
}
|
|
685
647
|
const group = field.type === "checkbox" ? new class extends CheckboxGroup {
|
|
686
|
-
constructor(...
|
|
687
|
-
super(...
|
|
648
|
+
constructor(..._args5) {
|
|
649
|
+
super(..._args5);
|
|
688
650
|
this.customId = field.id;
|
|
689
651
|
}
|
|
690
652
|
}() : new class extends RadioGroup {
|
|
691
|
-
constructor(...
|
|
692
|
-
super(...
|
|
653
|
+
constructor(..._args6) {
|
|
654
|
+
super(..._args6);
|
|
693
655
|
this.customId = field.id;
|
|
694
656
|
}
|
|
695
657
|
}();
|
|
@@ -710,8 +672,8 @@ var DiscordFormModal = class extends Modal {
|
|
|
710
672
|
this.components = params.fields.map((field) => {
|
|
711
673
|
const component = createModalFieldComponent(field);
|
|
712
674
|
class DynamicLabel extends Label {
|
|
713
|
-
constructor(...
|
|
714
|
-
super(...
|
|
675
|
+
constructor(..._args7) {
|
|
676
|
+
super(..._args7);
|
|
715
677
|
this.label = field.label;
|
|
716
678
|
this.description = field.description;
|
|
717
679
|
this.customId = field.id;
|
|
@@ -731,186 +693,6 @@ function createDiscordFormModal(entry) {
|
|
|
731
693
|
fields: entry.fields
|
|
732
694
|
});
|
|
733
695
|
}
|
|
734
|
-
// extensions/discord/src/approval-custom-id.ts
|
|
735
|
-
const DISCORD_APPROVAL_CUSTOM_ID_MAX_CHARS = 100;
|
|
736
|
-
function encodeDiscordApprovalCustomId(action) {
|
|
737
|
-
return `execapproval:kind=${action.approvalKind};id=${encodeURIComponent(action.approvalId)};action=${action.decision}`;
|
|
738
|
-
}
|
|
739
|
-
function encodeBoundedDiscordApprovalCustomId(action) {
|
|
740
|
-
const exact = encodeDiscordApprovalCustomId(action);
|
|
741
|
-
if (exact.length <= DISCORD_APPROVAL_CUSTOM_ID_MAX_CHARS) return exact;
|
|
742
|
-
return encodeDiscordApprovalCustomId({
|
|
743
|
-
...action,
|
|
744
|
-
approvalId: buildApprovalResolutionRef({
|
|
745
|
-
approvalId: action.approvalId,
|
|
746
|
-
approvalKind: action.approvalKind
|
|
747
|
-
})
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
function buildDiscordApprovalCustomId(action) {
|
|
751
|
-
if (!action.approvalId || action.approvalKind !== "exec" && action.approvalKind !== "plugin" && action.approvalKind !== "system-agent" || action.decision !== "allow-once" && action.decision !== "allow-always" && action.decision !== "deny") return;
|
|
752
|
-
return encodeBoundedDiscordApprovalCustomId(action);
|
|
753
|
-
}
|
|
754
|
-
function buildExecApprovalCustomId(approvalId, approvalKind, decision) {
|
|
755
|
-
return encodeBoundedDiscordApprovalCustomId({
|
|
756
|
-
type: "approval",
|
|
757
|
-
approvalId,
|
|
758
|
-
approvalKind,
|
|
759
|
-
decision
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
function parseExecApprovalData(data) {
|
|
763
|
-
if (!data || typeof data !== "object") return null;
|
|
764
|
-
const coerce = (value) => typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
765
|
-
const rawId = coerce(data.id);
|
|
766
|
-
const rawKind = coerce(data.kind);
|
|
767
|
-
const rawAction = coerce(data.action);
|
|
768
|
-
if (!rawId || rawKind !== "exec" && rawKind !== "plugin" && rawKind !== "system-agent") return null;
|
|
769
|
-
if (rawAction !== "allow-once" && rawAction !== "allow-always" && rawAction !== "deny") return null;
|
|
770
|
-
let approvalId;
|
|
771
|
-
try {
|
|
772
|
-
approvalId = decodeURIComponent(rawId);
|
|
773
|
-
} catch {
|
|
774
|
-
return null;
|
|
775
|
-
}
|
|
776
|
-
if (!approvalId) return null;
|
|
777
|
-
return {
|
|
778
|
-
approvalId,
|
|
779
|
-
approvalKind: rawKind,
|
|
780
|
-
action: rawAction
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
// extensions/discord/src/question-custom-id.ts
|
|
784
|
-
const QUESTION_RECORD_ID_PATTERN = /^ask_[a-f0-9]{32}$/u;
|
|
785
|
-
function buildDiscordQuestionCustomId(callback) {
|
|
786
|
-
if (!QUESTION_RECORD_ID_PATTERN.test(callback.questionId) || !Number.isInteger(callback.optionIndex) || callback.optionIndex < 0 || callback.optionIndex > 3) return;
|
|
787
|
-
return `ocq:id=${callback.questionId};i=${callback.optionIndex}`;
|
|
788
|
-
}
|
|
789
|
-
function parseDiscordQuestionData(data) {
|
|
790
|
-
const questionId = typeof data.id === "string" ? data.id : "";
|
|
791
|
-
const rawIndex = typeof data.i === "string" ? data.i : typeof data.i === "number" ? String(data.i) : "";
|
|
792
|
-
if (!QUESTION_RECORD_ID_PATTERN.test(questionId) || !/^[0-3]$/u.test(rawIndex)) return null;
|
|
793
|
-
return {
|
|
794
|
-
questionId,
|
|
795
|
-
optionIndex: Number(rawIndex)
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
// extensions/discord/src/shared-interactive.ts
|
|
799
|
-
var shared_interactive_exports = /* @__PURE__ */ __exportAll({
|
|
800
|
-
buildDiscordInteractiveComponents: () => buildDiscordInteractiveComponents,
|
|
801
|
-
buildDiscordPresentationComponents: () => buildDiscordPresentationComponents
|
|
802
|
-
});
|
|
803
|
-
const DISCORD_INTERACTIVE_BUTTON_ROW_SIZE = 5;
|
|
804
|
-
function buildDiscordButtonComponent(button, options) {
|
|
805
|
-
const action = resolveMessagePresentationButtonAction(button);
|
|
806
|
-
if (!action) return;
|
|
807
|
-
const component = {
|
|
808
|
-
label: button.label,
|
|
809
|
-
style: button.style ?? "secondary",
|
|
810
|
-
...button.disabled === true ? { disabled: true } : {}
|
|
811
|
-
};
|
|
812
|
-
if (action.type === "approval") {
|
|
813
|
-
const internalCustomId = buildDiscordApprovalCustomId(action);
|
|
814
|
-
return internalCustomId ? {
|
|
815
|
-
...component,
|
|
816
|
-
internalCustomId
|
|
817
|
-
} : void 0;
|
|
818
|
-
}
|
|
819
|
-
if (action.type === "question") {
|
|
820
|
-
if ("intent" in action) return;
|
|
821
|
-
const optionIndex = resolveAskUserQuestionOptionIndex({
|
|
822
|
-
questionOptionIndices: options.questionOptionIndices,
|
|
823
|
-
questionId: action.questionId,
|
|
824
|
-
optionValue: action.optionValue
|
|
825
|
-
});
|
|
826
|
-
if (optionIndex === void 0) return;
|
|
827
|
-
const internalCustomId = buildDiscordQuestionCustomId({
|
|
828
|
-
questionId: action.questionId,
|
|
829
|
-
optionIndex
|
|
830
|
-
});
|
|
831
|
-
return internalCustomId ? {
|
|
832
|
-
...component,
|
|
833
|
-
internalCustomId
|
|
834
|
-
} : void 0;
|
|
835
|
-
}
|
|
836
|
-
if (action.type === "web-app" && action.widgetId && isValidDiscordActivityWidgetId(action.widgetId)) component.internalCustomId = buildDiscordActivityCustomId(action.widgetId);
|
|
837
|
-
else if (action.type === "url" || action.type === "web-app") {
|
|
838
|
-
if (action.type === "web-app" && !action.url) return;
|
|
839
|
-
component.style = "link";
|
|
840
|
-
component.url = action.url;
|
|
841
|
-
} else {
|
|
842
|
-
component.callbackData = action.type === "command" ? action.command : action.value;
|
|
843
|
-
if (button.action?.type === "command" || button.action?.type === "callback") component.callbackDataKind = button.action.type;
|
|
844
|
-
}
|
|
845
|
-
if (button.reusable === true) component.reusable = true;
|
|
846
|
-
return component;
|
|
847
|
-
}
|
|
848
|
-
function appendDiscordSelectBlock(blocks, block) {
|
|
849
|
-
const options = [];
|
|
850
|
-
let callbackDataKind;
|
|
851
|
-
for (const option of block.options) {
|
|
852
|
-
const value = resolveMessagePresentationActionValue(resolveMessagePresentationOptionAction(option));
|
|
853
|
-
if (!value) continue;
|
|
854
|
-
const kind = option.action?.type;
|
|
855
|
-
if (kind !== void 0 && kind !== "command" && kind !== "callback" || options.length > 0 && callbackDataKind !== kind) return;
|
|
856
|
-
callbackDataKind = kind;
|
|
857
|
-
options.push({
|
|
858
|
-
label: option.label,
|
|
859
|
-
value
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
if (options.length === 0) return;
|
|
863
|
-
blocks.push({
|
|
864
|
-
type: "actions",
|
|
865
|
-
select: {
|
|
866
|
-
type: "string",
|
|
867
|
-
placeholder: block.placeholder,
|
|
868
|
-
options,
|
|
869
|
-
callbackDataKind
|
|
870
|
-
}
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* @deprecated Use buildDiscordPresentationComponents with MessagePresentation.
|
|
875
|
-
*/
|
|
876
|
-
function buildDiscordInteractiveComponents(interactive, options = {}) {
|
|
877
|
-
return buildDiscordPresentationComponents(interactive ? legacyInteractiveReplyToPresentation(interactive) : void 0, options);
|
|
878
|
-
}
|
|
879
|
-
function buildDiscordPresentationComponents(presentation, options = {}) {
|
|
880
|
-
if (!presentation) return;
|
|
881
|
-
const blocks = [];
|
|
882
|
-
if (presentation.title) blocks.push({
|
|
883
|
-
type: "text",
|
|
884
|
-
text: presentation.title
|
|
885
|
-
});
|
|
886
|
-
for (const block of presentation.blocks) {
|
|
887
|
-
if (block.type === "text" || block.type === "context") {
|
|
888
|
-
const text = block.text;
|
|
889
|
-
if (text) blocks.push({
|
|
890
|
-
type: "text",
|
|
891
|
-
text: block.type === "context" ? `-# ${text}` : text
|
|
892
|
-
});
|
|
893
|
-
continue;
|
|
894
|
-
}
|
|
895
|
-
if (block.type === "divider") {
|
|
896
|
-
blocks.push({ type: "separator" });
|
|
897
|
-
continue;
|
|
898
|
-
}
|
|
899
|
-
if (block.type === "buttons") {
|
|
900
|
-
const components = block.buttons.flatMap((button) => {
|
|
901
|
-
const component = buildDiscordButtonComponent(button, options);
|
|
902
|
-
return component ? [component] : [];
|
|
903
|
-
});
|
|
904
|
-
for (let index = 0; index < components.length; index += DISCORD_INTERACTIVE_BUTTON_ROW_SIZE) blocks.push({
|
|
905
|
-
type: "actions",
|
|
906
|
-
buttons: components.slice(index, index + DISCORD_INTERACTIVE_BUTTON_ROW_SIZE)
|
|
907
|
-
});
|
|
908
|
-
continue;
|
|
909
|
-
}
|
|
910
|
-
if (block.type === "select") appendDiscordSelectBlock(blocks, block);
|
|
911
|
-
}
|
|
912
|
-
return blocks.length ? { blocks } : void 0;
|
|
913
|
-
}
|
|
914
696
|
// extensions/discord/src/components.ts
|
|
915
697
|
var components_exports = /* @__PURE__ */ __exportAll({
|
|
916
698
|
DISCORD_COMPONENT_ATTACHMENT_PREFIX: () => DISCORD_COMPONENT_ATTACHMENT_PREFIX,
|
|
@@ -939,4 +721,4 @@ function formatDiscordComponentEventText(params) {
|
|
|
939
721
|
if (values.length === 0) return `Updated "${params.label}".`;
|
|
940
722
|
return `Selected ${values.join(", ")} from "${params.label}".`;
|
|
941
723
|
}
|
|
942
|
-
export {
|
|
724
|
+
export { buildDiscordComponentMessage as a, coerceDiscordComponentParam as c, createDiscordFormModal as i, readDiscordComponentSpec as l, formatDiscordComponentEventText as n, buildDiscordComponentMessageFlags as o, DiscordFormModal as r, DISCORD_COMPONENT_ATTACHMENT_PREFIX as s, components_exports as t, resolveDiscordComponentAttachmentName as u };
|