@openclaw/discord 2026.10.2 → 2026.10.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/account-inspect-8cCu6uPG.mjs +31 -0
- package/dist/.setup/{accounts-HE9-mj1L.mjs → accounts-ljrzXBJi.mjs} +47 -45
- package/dist/.setup/{allow-list-vxkG9_JD.mjs → allow-list-B_ToXtew.mjs} +34 -101
- package/dist/.setup/{api-DlNUkDqj.mjs → api-CtmE1OUN.mjs} +25 -31
- package/dist/.setup/{approval-handler.runtime-DmnEa54W.mjs → approval-handler.runtime-D7FoZSn0.mjs} +30 -53
- package/dist/.setup/{approval-message-updates-B0jdSqOj.mjs → approval-message-updates-CIGByUcE.mjs} +2 -2
- package/dist/.setup/{audit-BpikUwN_.mjs → audit-zSawfbsN.mjs} +5 -8
- package/dist/.setup/{channel-Dr-AUnGt.mjs → channel-DI7DMzu0.mjs} +136 -215
- package/dist/.setup/{channel-access-BRp3Y-rF.mjs → channel-access-DasWY_OV.mjs} +6 -7
- package/dist/.setup/{channel.setup-BmNvkidb.mjs → channel.setup-DdFVN1mr.mjs} +35 -64
- package/dist/.setup/{components-DLJR0xU-.mjs → components-HN9052L1.mjs} +123 -146
- package/dist/.setup/{config-schema-BQWfnSCx.mjs → config-schema-_uBILpQf.mjs} +7 -3
- package/dist/.setup/{conversation-binding-route-DicJC1Lj.mjs → conversation-binding-route-DTjCBx-O.mjs} +1 -1
- package/dist/.setup/{directory-config-gqsdcplU.mjs → directory-config-3iVub-3m.mjs} +1 -1
- package/dist/.setup/{directory-live-Bipr0eUJ.mjs → directory-live-DLygQVtW.mjs} +18 -22
- package/dist/.setup/{discord-9gysrhzp.mjs → discord-BGqgx-yd.mjs} +686 -854
- package/dist/.setup/{doctor-B2bskDcF.mjs → doctor-DSrNJ7m2.mjs} +36 -47
- package/dist/.setup/{doctor-contract-Bg3NPAMw.mjs → doctor-contract-Bwv8EuQ_.mjs} +7 -16
- package/dist/.setup/{handle-action-UmkjXBfo.mjs → handle-action-CXH1h1tq.mjs} +25 -38
- package/dist/.setup/{handle-action.guild-admin-CB4sc9VV.mjs → handle-action.guild-admin-CHKW6PIs.mjs} +25 -31
- package/dist/.setup/{live-policy-config-VxexfRKo.mjs → live-policy-config-BPoB3eQi.mjs} +1 -1
- package/dist/.setup/{message-handler-BK69A-NB.mjs → message-handler-Ii_etru1.mjs} +9 -14
- package/dist/.setup/{message-handler.preflight-DFpsh90H.mjs → message-handler.preflight-C7YuSRl_.mjs} +79 -128
- package/dist/.setup/{message-handler.preflight-pluralkit-BXGGVmpe.mjs → message-handler.preflight-pluralkit-C3iAG--b.mjs} +6 -6
- package/dist/.setup/{message-handler.process-TKoqcqIP.mjs → message-handler.process-ClgWYH6o.mjs} +234 -206
- package/dist/.setup/{outbound-adapter-D4wRAb5S.mjs → outbound-adapter-D8OOIuKn.mjs} +73 -112
- package/dist/.setup/{outbound-session-route-BvBH4LC6.mjs → outbound-session-route-B0Hpwn3Q.mjs} +57 -115
- package/dist/.setup/output-activity-uBpMSX75.mjs +11 -0
- package/dist/.setup/{pluralkit-a6_NLfH9.mjs → pluralkit-B64dfq_j.mjs} +3 -1
- package/dist/.setup/{preflight-audio-DHGIHEpv.mjs → preflight-audio-wWgsZG5F.mjs} +1 -5
- package/dist/.setup/{presence-cache-Dg3_dADn.mjs → presence-cache-DCeTsL73.mjs} +3 -6
- package/dist/.setup/{probe-BwSKpnZf.mjs → probe-D3P1x4aN.mjs} +10 -18
- package/dist/.setup/{provider-YP8gN9_o.mjs → provider-D9EzOfG8.mjs} +2990 -3903
- package/dist/.setup/{provider-session.runtime-D1gkPxHT.mjs → provider-session.runtime-CsnRvddI.mjs} +5 -5
- package/dist/.setup/provider.runtime-BQVcM7Pg.mjs +2 -0
- package/dist/.setup/{realtime-session.runtime-BKUQBy1u.mjs → realtime-session.runtime-CxGBk8H-.mjs} +69 -98
- package/dist/.setup/{receive-recovery-DgkX7Qvi.mjs → receive-recovery-eVmK2_hl.mjs} +2 -12
- package/dist/.setup/resolve-allowlist-common-DNSsUQRF.mjs +66 -0
- package/dist/.setup/resolve-channels-UdT38DzU.mjs +173 -0
- package/dist/.setup/{resolve-users-DNrwvunm.mjs → resolve-users-DnCsrXZ_.mjs} +12 -41
- package/dist/.setup/{runtime-CESTexGn.mjs → runtime-CRTkKU1G.mjs} +202 -313
- package/dist/.setup/{runtime-DPcmPST9.mjs → runtime-DPm3gZXk.mjs} +2 -2
- package/dist/.setup/{secret-config-contract-uOE2J7yM.mjs → secret-config-contract-CIsH7R3B.mjs} +9 -18
- package/dist/.setup/{security-audit-D42cp5N7.mjs → security-audit-BFT84Uny.mjs} +1 -2
- package/dist/.setup/security-contract-DNyyjTZZ.mjs +19 -0
- package/dist/.setup/{send-CJk3VP5q.mjs → send-DbILKgcm.mjs} +184 -241
- package/dist/.setup/{send.components-dPljuV24.mjs → send.components-FxOS3CeP.mjs} +47 -63
- package/dist/.setup/{send.outbound-rOboMO_6.mjs → send.outbound-_jx4Xpd3.mjs} +178 -202
- package/dist/.setup/{send.receipt-DVOg2Oaw.mjs → send.receipt-BAlzXd8e.mjs} +33 -109
- package/dist/.setup/{send.shared-C4CN24D9.mjs → send.shared-CjQ4jbMA.mjs} +97 -153
- package/dist/.setup/{sender-identity-AHpUNr72.mjs → sender-identity-BNBvGt1l.mjs} +1 -1
- package/dist/.setup/setup-plugin-api-xfOFmxHP.mjs +3 -0
- package/dist/.setup/{shared-BoBnM5kM.mjs → shared-CestGDpq.mjs} +30 -20
- package/dist/.setup/{subagent-hooks-HH8Uy9cx.mjs → subagent-hooks-CME7dSGf.mjs} +5 -10
- package/dist/.setup/{system-events-Cwxaww8i.mjs → system-events-BwwSDCw4.mjs} +2 -2
- package/dist/.setup/target-parsing-C-HyNxcE.mjs +48 -0
- package/dist/.setup/{target-resolver-CSFoPQ12.mjs → target-resolver-Bse8fuTi.mjs} +11 -27
- package/dist/.setup/targets-DZJjkzwv.mjs +3 -0
- package/dist/.setup/{thread-bindings-DjQCkmsd.mjs → thread-bindings-0hPTSK14.mjs} +61 -52
- package/dist/.setup/{thread-bindings.manager-D2-GYZ5s.mjs → thread-bindings.manager-CdNa6UIs.mjs} +138 -211
- package/dist/.setup/{thread-bindings.session-updates-Bu_CGr_O.mjs → thread-bindings.session-updates-DGSljVf6.mjs} +60 -99
- package/dist/.setup/threading-BKe3E3tp.mjs +246 -0
- package/dist/.setup/{timeouts-pun7VJ02.mjs → timeouts-CuNARfyw.mjs} +10 -18
- package/dist/.setup/{transcripts-source-CaZQnGRH.mjs → transcripts-source-0qQYVu2H.mjs} +50 -368
- package/dist/.setup/{voice-runtime-DDymtIw8.mjs → voice-runtime-QlZJ4sHv.mjs} +166 -322
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +77 -120
- package/dist/api.js +19 -18
- 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/doctor-contract-api.js +1 -1
- package/dist/runtime-api.js +21 -20
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/security-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 +38 -57
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/crypto.d.ts +2 -2
- package/node_modules/@types/node/dgram.d.ts +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/zlib.d.ts +6 -0
- package/node_modules/@types/ws/README.md +1 -1
- package/node_modules/@types/ws/index.d.mts +4 -0
- package/node_modules/@types/ws/index.d.ts +4 -0
- package/node_modules/@types/ws/package.json +3 -3
- package/node_modules/discord-api-types/_generated_/rest/v10/interfaces.d.ts +21 -0
- package/node_modules/discord-api-types/_generated_/rest/v10/interfaces.d.ts.map +1 -1
- package/node_modules/discord-api-types/_generated_/rest/v9/interfaces.d.ts +21 -0
- package/node_modules/discord-api-types/_generated_/rest/v9/interfaces.d.ts.map +1 -1
- package/node_modules/discord-api-types/globals.d.ts +6 -0
- package/node_modules/discord-api-types/globals.d.ts.map +1 -1
- package/node_modules/discord-api-types/globals.js +6 -0
- package/node_modules/discord-api-types/globals.js.map +1 -1
- package/node_modules/discord-api-types/package.json +3 -3
- package/node_modules/discord-api-types/payloads/index.mjs +1 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.d.ts +207 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.js +25 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/payloads/v10/autoModeration.d.ts +1 -1
- package/node_modules/discord-api-types/payloads/v10/autoModeration.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/guild.d.ts +27 -23
- package/node_modules/discord-api-types/payloads/v10/guild.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/guild.js +26 -22
- package/node_modules/discord-api-types/payloads/v10/guild.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.d.ts +1 -0
- package/node_modules/discord-api-types/payloads/v10/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.js +1 -0
- package/node_modules/discord-api-types/payloads/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.mjs +1 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.d.ts +207 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.js +25 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/payloads/v9/autoModeration.d.ts +1 -1
- package/node_modules/discord-api-types/payloads/v9/autoModeration.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/guild.d.ts +27 -23
- package/node_modules/discord-api-types/payloads/v9/guild.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/guild.js +26 -22
- package/node_modules/discord-api-types/payloads/v9/guild.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.d.ts +1 -0
- package/node_modules/discord-api-types/payloads/v9/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.js +1 -0
- package/node_modules/discord-api-types/payloads/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.mjs +1 -0
- package/node_modules/discord-api-types/rest/common.d.ts +2 -0
- package/node_modules/discord-api-types/rest/common.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/common.js +2 -0
- package/node_modules/discord-api-types/rest/common.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.d.ts +70 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.js +3 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/rest/v10/index.d.ts +1 -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 +29 -0
- package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts +4 -2
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v10/user.d.ts +2 -2
- package/node_modules/discord-api-types/rest/v10/user.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.d.ts +70 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.js +3 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/rest/v9/index.d.ts +1 -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 +29 -0
- package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts +4 -2
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/user.d.ts +2 -2
- package/node_modules/discord-api-types/rest/v9/user.d.ts.map +1 -1
- package/node_modules/discord-api-types/v10.mjs +1 -0
- package/node_modules/discord-api-types/v9.mjs +1 -0
- package/node_modules/micromark/dev/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/compile.js +14 -4
- package/node_modules/micromark/dev/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/create-tokenizer.js +7 -6
- package/node_modules/micromark/dev/lib/initialize/document.js +25 -21
- package/node_modules/micromark/dev/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/initialize/text.js +10 -6
- package/node_modules/micromark/dev/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/preprocess.js +19 -21
- package/node_modules/micromark/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/lib/compile.js +37 -29
- package/node_modules/micromark/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/lib/create-tokenizer.js +37 -35
- package/node_modules/micromark/lib/initialize/document.js +21 -13
- package/node_modules/micromark/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/lib/initialize/text.js +7 -3
- package/node_modules/micromark/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/lib/preprocess.js +16 -19
- package/node_modules/micromark/package.json +2 -15
- package/node_modules/micromark-core-commonmark/dev/lib/attention.js +18 -24
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.js +1 -43
- package/node_modules/micromark-core-commonmark/dev/lib/code-indented.js +19 -43
- package/node_modules/micromark-core-commonmark/dev/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.js +2 -53
- package/node_modules/micromark-core-commonmark/dev/lib/label-end.js +14 -12
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.js +67 -0
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.js +8 -5
- package/node_modules/micromark-core-commonmark/lib/attention.js +14 -24
- package/node_modules/micromark-core-commonmark/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/code-fenced.js +1 -39
- package/node_modules/micromark-core-commonmark/lib/code-indented.js +11 -29
- package/node_modules/micromark-core-commonmark/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/html-flow.js +2 -51
- package/node_modules/micromark-core-commonmark/lib/label-end.js +11 -10
- package/node_modules/micromark-core-commonmark/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-image.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-link.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
- package/node_modules/micromark-core-commonmark/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/setext-underline.js +7 -5
- package/node_modules/micromark-core-commonmark/package.json +4 -16
- package/node_modules/micromark-factory-space/dev/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/dev/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/dev/index.js +58 -3
- package/node_modules/micromark-factory-space/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/index.js +55 -3
- package/node_modules/micromark-factory-space/package.json +1 -10
- package/node_modules/micromark-factory-space/readme.md +25 -25
- package/node_modules/micromark-util-edit-map/dev/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/dev/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/dev/index.js +237 -0
- package/node_modules/micromark-util-edit-map/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/index.js +225 -0
- package/node_modules/micromark-util-edit-map/license +22 -0
- package/node_modules/micromark-util-edit-map/package.json +48 -0
- package/node_modules/micromark-util-edit-map/readme.md +234 -0
- package/node_modules/micromark-util-types/index.d.ts +6 -3
- package/node_modules/micromark-util-types/package.json +2 -36
- package/node_modules/ws/lib/websocket.js +17 -3
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +3 -6
- package/package.json +7 -12
- package/dist/.setup/account-inspect-DsER5ILV.mjs +0 -45
- package/dist/.setup/provider.runtime-CZ51OIgD.mjs +0 -2
- package/dist/.setup/resolve-allowlist-common-BUyU3C-T.mjs +0 -27
- package/dist/.setup/resolve-channels-DA6QlhZN.mjs +0 -246
- package/dist/.setup/security-contract-DSHk7I2w.mjs +0 -26
- package/dist/.setup/setup-plugin-api-BVlCz3fm.mjs +0 -3
- package/dist/.setup/targets-bqXQENmX.mjs +0 -3
- package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as isDiscordThreadChannelType, l as resolveDiscordChannelConfigWithFallback, n as hasConfiguredDiscordChannels, o as normalizeDiscordSlug, r as isDiscordGroupAllowedByPolicy, y as resolveGroupDmAllow } from "./allow-list-
|
|
3
|
-
import { C as hasAnyChannelPermissionDiscord, F as createDiscordRuntimeAccountContext, U as getGateway, _ as canManageGuildMemberRoleDiscord, b as fetchChannelPermissionsDiscord, n as buildDiscordTextChunks, u as resolveDiscordTargetChannelId, v as canManageGuildRoleDiscord, w as hasAnyGuildPermissionDiscord, y as canViewDiscordGuildChannel } from "./send.shared-
|
|
4
|
-
import { n as getPresence } from "./presence-cache-
|
|
5
|
-
import { a as createReusableDiscordReplyReference,
|
|
6
|
-
import {
|
|
7
|
-
import { r as
|
|
8
|
-
import "./
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
1
|
+
import { c as resolveDefaultDiscordAccountId, s as mergeDiscordAccountConfig, t as createDiscordActionGate } from "./accounts-ljrzXBJi.mjs";
|
|
2
|
+
import { A as isDiscordThreadChannelType, l as resolveDiscordChannelConfigWithFallback, n as hasConfiguredDiscordChannels, o as normalizeDiscordSlug, r as isDiscordGroupAllowedByPolicy, y as resolveGroupDmAllow } from "./allow-list-B_ToXtew.mjs";
|
|
3
|
+
import { C as hasAnyChannelPermissionDiscord, F as createDiscordRuntimeAccountContext, U as getGateway, _ as canManageGuildMemberRoleDiscord, b as fetchChannelPermissionsDiscord, n as buildDiscordTextChunks, u as resolveDiscordTargetChannelId, v as canManageGuildRoleDiscord, w as hasAnyGuildPermissionDiscord, y as canViewDiscordGuildChannel } from "./send.shared-CjQ4jbMA.mjs";
|
|
4
|
+
import { n as getPresence } from "./presence-cache-DCeTsL73.mjs";
|
|
5
|
+
import { a as createReusableDiscordReplyReference, s as resolveDiscordReplyReference } from "./send.receipt-BAlzXd8e.mjs";
|
|
6
|
+
import { n as resolveDiscordChannelId, t as parseDiscordTarget } from "./target-parsing-C-HyNxcE.mjs";
|
|
7
|
+
import { A as listScheduledEventsDiscord, B as moveChannelDiscord, C as fetchChannelInfoDiscord, D as fetchVoiceStatusDiscord, E as fetchRoleInfoDiscord, F as uploadEmojiDiscord, H as setChannelPermissionDiscord, I as uploadStickerDiscord, L as createChannelDiscord, M as resolveEventCoverImage, N as timeoutMemberDiscord, O as kickMemberDiscord, P as listGuildEmojisDiscord, R as deleteChannelDiscord, S as createScheduledEventDiscord, T as fetchMemberInfoDiscord, V as removeChannelPermissionDiscord, _ as readMessagesDiscord, a as removeReactionDiscord, b as addRoleDiscord, d as deleteMessageDiscord, f as editMessageDiscord, g as pinMessageDiscord, h as listThreadsDiscord, i as removeOwnReactionsDiscord, j as removeRoleDiscord, k as listGuildChannelsDiscord, l as DiscordThreadInitialMessageError, m as listPinsDiscord, n as fetchReactionsDiscord, p as fetchMessageDiscord, r as reactMessageDiscord, s as sendVoiceMessageDiscord, u as createThreadDiscord, v as searchMessagesDiscord, w as fetchGuildInfoDiscord, x as banMemberDiscord, y as unpinMessageDiscord, z as editChannelDiscord } from "./send-DbILKgcm.mjs";
|
|
8
|
+
import { r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-_jx4Xpd3.mjs";
|
|
9
|
+
import "./targets-DZJjkzwv.mjs";
|
|
10
|
+
import { h as readDiscordComponentSpec, m as coerceDiscordComponentParam } from "./components-HN9052L1.mjs";
|
|
11
|
+
import { r as sendDiscordComponentMessage } from "./send.components-FxOS3CeP.mjs";
|
|
11
12
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
12
13
|
import { asBoolean, asOptionalRecord, isRecord, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
13
14
|
import { assertMediaNotDataUrl, jsonResult, parseAvailableTags, readNonNegativeIntegerParam, readPositiveIntegerParam, readReactionParams, readStringArrayParam, readStringParam, withNormalizedTimestamp } from "openclaw/plugin-sdk/channel-actions";
|
|
@@ -30,9 +31,6 @@ function readDiscordChannelType(value) {
|
|
|
30
31
|
const type = value.type;
|
|
31
32
|
return typeof type === "number" ? type : void 0;
|
|
32
33
|
}
|
|
33
|
-
function isDiscordThreadChannel(value) {
|
|
34
|
-
return isDiscordThreadChannelType(readDiscordChannelType(value));
|
|
35
|
-
}
|
|
36
34
|
function filterDiscordActiveThreadList(params) {
|
|
37
35
|
const response = asOptionalRecord(params.value);
|
|
38
36
|
if (!Array.isArray(response?.threads) || !Array.isArray(response.members)) throw new Error("Unexpected Discord response for active thread list.");
|
|
@@ -87,8 +85,7 @@ const DISCORD_AUTO_ARCHIVE_MINUTES = /* @__PURE__ */ new Set([
|
|
|
87
85
|
10080
|
|
88
86
|
]);
|
|
89
87
|
function readDiscordParentIdParam(params) {
|
|
90
|
-
|
|
91
|
-
return readStringParam(params, "parentId");
|
|
88
|
+
return params.clearParent === true || params.parentId === null ? null : readStringParam(params, "parentId");
|
|
92
89
|
}
|
|
93
90
|
/**
|
|
94
91
|
* Reads Discord auto-archive duration minutes and rejects values Discord will
|
|
@@ -96,8 +93,7 @@ function readDiscordParentIdParam(params) {
|
|
|
96
93
|
*/
|
|
97
94
|
function readDiscordAutoArchiveDurationParam(params, key) {
|
|
98
95
|
const value = readPositiveIntegerParam(params, key);
|
|
99
|
-
if (value
|
|
100
|
-
if (!DISCORD_AUTO_ARCHIVE_MINUTES.has(value)) throw new Error(`${key} must be one of 60, 1440, 4320, or 10080 minutes`);
|
|
96
|
+
if (value !== void 0 && !DISCORD_AUTO_ARCHIVE_MINUTES.has(value)) throw new Error(`${key} must be one of 60, 1440, 4320, or 10080 minutes`);
|
|
101
97
|
return value;
|
|
102
98
|
}
|
|
103
99
|
function createDiscordActionOptions(params) {
|
|
@@ -154,14 +150,10 @@ function allowsAllDiscordGuildChannels(channels) {
|
|
|
154
150
|
function resolveDiscordActionGuildEntry(params) {
|
|
155
151
|
const guildId = params.guildId?.trim();
|
|
156
152
|
if (!params.guilds) return null;
|
|
157
|
-
if (guildId && params.guilds[guildId]) return {
|
|
158
|
-
...params.guilds[guildId],
|
|
159
|
-
id: guildId
|
|
160
|
-
};
|
|
161
153
|
if (guildId) {
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
...
|
|
154
|
+
const guild = params.guilds[guildId] || Object.values(params.guilds).find((entry) => entry?.id === guildId);
|
|
155
|
+
if (guild) return {
|
|
156
|
+
...guild,
|
|
165
157
|
id: guildId
|
|
166
158
|
};
|
|
167
159
|
}
|
|
@@ -227,7 +219,7 @@ async function buildDiscordReadTarget(params) {
|
|
|
227
219
|
...params.guildId ? { guildId: params.guildId } : {},
|
|
228
220
|
...channelName ? { channelName } : {},
|
|
229
221
|
...channelType !== void 0 ? { channelType } : {},
|
|
230
|
-
...
|
|
222
|
+
...isDiscordThreadChannelType(channelType) ? { scope: "thread" } : {}
|
|
231
223
|
};
|
|
232
224
|
const ancestry = await resolveDiscordReadAncestry({
|
|
233
225
|
channelId: params.channelId,
|
|
@@ -256,42 +248,41 @@ function isDiscordReadAncestryAllowed(params) {
|
|
|
256
248
|
}
|
|
257
249
|
return params.target.ancestryComplete || !hasExplicitlyDisabledDiscordChannels(params.guildInfo?.channels);
|
|
258
250
|
}
|
|
251
|
+
function isDiscordGuildReadTargetVisible(guildInfo, target) {
|
|
252
|
+
if (!isDiscordReadAncestryAllowed({
|
|
253
|
+
guildInfo,
|
|
254
|
+
target
|
|
255
|
+
})) return false;
|
|
256
|
+
const channelConfig = resolveDiscordChannelConfigWithFallback({
|
|
257
|
+
...target,
|
|
258
|
+
guildInfo
|
|
259
|
+
});
|
|
260
|
+
return !channelConfig?.matchSource || channelConfig.allowed;
|
|
261
|
+
}
|
|
259
262
|
function isDiscordReadTargetAllowedInGuild(params) {
|
|
260
263
|
if (!params.target.metadataKnown) {
|
|
261
264
|
if (hasExplicitlyDisabledDiscordChannels(params.guildInfo?.channels)) return false;
|
|
262
|
-
|
|
265
|
+
const channelEntry = params.guildInfo?.channels?.[params.target.channelId];
|
|
266
|
+
if (!channelEntry || channelEntry.enabled === false) return false;
|
|
267
|
+
} else {
|
|
268
|
+
if (!isDiscordReadAncestryAllowed(params)) return false;
|
|
269
|
+
if (resolveDiscordChannelConfigWithFallback({
|
|
270
|
+
...params.target,
|
|
271
|
+
guildInfo: params.guildInfo
|
|
272
|
+
})?.allowed === false) return false;
|
|
263
273
|
}
|
|
264
|
-
if (!isDiscordReadAncestryAllowed(params)) return false;
|
|
265
|
-
if (resolveDiscordChannelConfigWithFallback({
|
|
266
|
-
...params.target,
|
|
267
|
-
guildInfo: params.guildInfo
|
|
268
|
-
})?.allowed === false) return false;
|
|
269
274
|
return isDiscordGroupAllowedByPolicy({
|
|
270
275
|
groupPolicy: params.groupPolicy,
|
|
271
276
|
guildAllowlisted: Boolean(params.guildInfo),
|
|
272
|
-
channelAllowlistConfigured: hasConfiguredDiscordChannels(params.guildInfo?.channels),
|
|
277
|
+
channelAllowlistConfigured: !params.target.metadataKnown || hasConfiguredDiscordChannels(params.guildInfo?.channels),
|
|
273
278
|
channelAllowed: true
|
|
274
279
|
});
|
|
275
280
|
}
|
|
276
|
-
function isDiscordReadTargetExplicitlyAllowedById(params) {
|
|
277
|
-
const channelEntry = params.guildInfo?.channels?.[params.target.channelId];
|
|
278
|
-
if (!channelEntry || channelEntry.enabled === false) return false;
|
|
279
|
-
return isDiscordGroupAllowedByPolicy({
|
|
280
|
-
groupPolicy: params.groupPolicy,
|
|
281
|
-
guildAllowlisted: Boolean(params.guildInfo),
|
|
282
|
-
channelAllowlistConfigured: true,
|
|
283
|
-
channelAllowed: true
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
function hasExplicitlyDisabledDiscordChannelConfig(guilds) {
|
|
287
|
-
return Object.values(guilds ?? {}).some((guild) => hasExplicitlyDisabledDiscordChannels(guild?.channels));
|
|
288
|
-
}
|
|
289
281
|
function hasExplicitlyDisabledDiscordChannels(channels) {
|
|
290
282
|
return Object.values(channels ?? {}).some((channel) => channel.enabled === false);
|
|
291
283
|
}
|
|
292
284
|
function createDiscordMessagingActionContext(params) {
|
|
293
285
|
const accountId = readStringParam(params.input, "accountId");
|
|
294
|
-
const cfgOptions = { cfg: params.cfg };
|
|
295
286
|
const accountConfig = mergeDiscordAccountConfig(params.cfg, accountId ?? resolveDefaultDiscordAccountId(params.cfg));
|
|
296
287
|
const guilds = accountConfig.guilds;
|
|
297
288
|
const { groupPolicy } = resolveOpenProviderRuntimeGroupPolicy({
|
|
@@ -318,10 +309,10 @@ function createDiscordMessagingActionContext(params) {
|
|
|
318
309
|
return false;
|
|
319
310
|
}
|
|
320
311
|
};
|
|
321
|
-
const reactionRuntimeOptions =
|
|
312
|
+
const reactionRuntimeOptions = createDiscordRuntimeAccountContext({
|
|
322
313
|
cfg: params.cfg,
|
|
323
314
|
accountId: resolvedReactionAccountId
|
|
324
|
-
})
|
|
315
|
+
});
|
|
325
316
|
const guildNameById = /* @__PURE__ */ new Map();
|
|
326
317
|
const resolveGuildName = async (guildId) => {
|
|
327
318
|
if (guildNameById.has(guildId)) return guildNameById.get(guildId) ?? null;
|
|
@@ -342,14 +333,12 @@ function createDiscordMessagingActionContext(params) {
|
|
|
342
333
|
});
|
|
343
334
|
if (direct || !guildId) return direct;
|
|
344
335
|
const guildName = await resolveGuildName(guildId);
|
|
345
|
-
|
|
336
|
+
return resolveDiscordActionGuildEntry({
|
|
346
337
|
guilds,
|
|
347
338
|
guildId,
|
|
348
339
|
guildName: guildName ?? void 0,
|
|
349
340
|
includeWildcard: false
|
|
350
|
-
})
|
|
351
|
-
if (named) return named;
|
|
352
|
-
return resolveDiscordActionGuildEntry({
|
|
341
|
+
}) ?? resolveDiscordActionGuildEntry({
|
|
353
342
|
guilds,
|
|
354
343
|
guildId
|
|
355
344
|
});
|
|
@@ -389,22 +378,13 @@ function createDiscordMessagingActionContext(params) {
|
|
|
389
378
|
channelName: target.channelName,
|
|
390
379
|
channelSlug: target.channelSlug
|
|
391
380
|
}));
|
|
392
|
-
if (!target.metadataKnown) return groupPolicy !== "disabled" && directDmEnabled && groupDmEnabled && !
|
|
381
|
+
if (!target.metadataKnown) return groupPolicy !== "disabled" && directDmEnabled && groupDmEnabled && !Object.values(guilds ?? {}).some((guild) => hasExplicitlyDisabledDiscordChannels(guild?.channels));
|
|
393
382
|
if (!target.guildId) {
|
|
394
383
|
if (target.channelType === ChannelType.GroupDM) return groupDmEnabled;
|
|
395
384
|
if (target.channelType === ChannelType.DM) return directDmEnabled;
|
|
396
385
|
return directDmEnabled && groupDmEnabled;
|
|
397
386
|
}
|
|
398
|
-
|
|
399
|
-
if (!isDiscordReadAncestryAllowed({
|
|
400
|
-
guildInfo,
|
|
401
|
-
target
|
|
402
|
-
})) return false;
|
|
403
|
-
const channelConfig = resolveDiscordChannelConfigWithFallback({
|
|
404
|
-
...target,
|
|
405
|
-
guildInfo
|
|
406
|
-
});
|
|
407
|
-
return !channelConfig?.matchSource || channelConfig.allowed;
|
|
387
|
+
return groupPolicy !== "disabled" && isDiscordGuildReadTargetVisible(guildInfo, target);
|
|
408
388
|
};
|
|
409
389
|
return {
|
|
410
390
|
action: params.action,
|
|
@@ -422,23 +402,18 @@ function createDiscordMessagingActionContext(params) {
|
|
|
422
402
|
const currentConversation = isCurrentReadTarget(targetChannelId);
|
|
423
403
|
if (guildId && target.metadataKnown && target.guildId !== guildId) throw new Error("Discord read target channel is not allowed.");
|
|
424
404
|
const targetGuildId = guildId || target.guildId;
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
if (directOperator && isExpandedReadTargetEnabled(guildInfo, target, false) || currentConversation && isExpandedReadTargetEnabled(guildInfo, target, true)) return;
|
|
428
|
-
if (!isDiscordReadTargetAllowedInGuild({
|
|
429
|
-
groupPolicy,
|
|
430
|
-
guildInfo,
|
|
431
|
-
target
|
|
432
|
-
})) throw new Error("Discord read target channel is not allowed.");
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
const allowed = !target.metadataKnown && Object.values(guilds ?? {}).some((guildInfo) => isDiscordReadTargetAllowedInGuild({
|
|
405
|
+
const guildInfo = targetGuildId ? await resolveReadGuildEntry(targetGuildId) : null;
|
|
406
|
+
const allowedWithoutGuild = !targetGuildId && !target.metadataKnown && Object.values(guilds ?? {}).some((candidateGuildInfo) => isDiscordReadTargetAllowedInGuild({
|
|
436
407
|
groupPolicy,
|
|
437
|
-
guildInfo:
|
|
408
|
+
guildInfo: candidateGuildInfo ?? null,
|
|
438
409
|
target
|
|
439
410
|
}));
|
|
440
|
-
if (directOperator && isExpandedReadTargetEnabled(
|
|
441
|
-
if (!
|
|
411
|
+
if (directOperator && isExpandedReadTargetEnabled(guildInfo, target, false) || currentConversation && isExpandedReadTargetEnabled(guildInfo, target, true)) return;
|
|
412
|
+
if (!(targetGuildId ? isDiscordReadTargetAllowedInGuild({
|
|
413
|
+
groupPolicy,
|
|
414
|
+
guildInfo,
|
|
415
|
+
target
|
|
416
|
+
}) : allowedWithoutGuild)) throw new Error("Discord read target channel is not allowed.");
|
|
442
417
|
},
|
|
443
418
|
assertGuildReadTargetAllowed: async ({ guildId, channelTargetRequiredMessage, filteredResults }) => {
|
|
444
419
|
const guildInfo = await resolveReadGuildEntry(guildId);
|
|
@@ -478,22 +453,13 @@ function createDiscordMessagingActionContext(params) {
|
|
|
478
453
|
for (const channel of channels) {
|
|
479
454
|
const channelId = readDiscordChannelStringField(channel, "id");
|
|
480
455
|
if (!channelId) continue;
|
|
481
|
-
|
|
456
|
+
if (isDiscordGuildReadTargetVisible(guildInfo, await buildDiscordReadTarget({
|
|
482
457
|
channelId,
|
|
483
458
|
channelInfo: channel,
|
|
484
459
|
guildId,
|
|
485
460
|
fallbackSlug: channelId,
|
|
486
461
|
loadChannel: async (parentId) => channelById.get(parentId)
|
|
487
|
-
});
|
|
488
|
-
if (!isDiscordReadAncestryAllowed({
|
|
489
|
-
guildInfo,
|
|
490
|
-
target
|
|
491
|
-
})) continue;
|
|
492
|
-
const channelConfig = resolveDiscordChannelConfigWithFallback({
|
|
493
|
-
...target,
|
|
494
|
-
guildInfo
|
|
495
|
-
});
|
|
496
|
-
if (!channelConfig?.matchSource || channelConfig.allowed) visibleChannels.push(channel);
|
|
462
|
+
}))) visibleChannels.push(channel);
|
|
497
463
|
}
|
|
498
464
|
return visibleChannels;
|
|
499
465
|
},
|
|
@@ -521,7 +487,7 @@ function createDiscordMessagingActionContext(params) {
|
|
|
521
487
|
},
|
|
522
488
|
withOpts,
|
|
523
489
|
withReactionRuntimeOptions: (extra) => ({
|
|
524
|
-
...reactionRuntimeOptions
|
|
490
|
+
...reactionRuntimeOptions,
|
|
525
491
|
...extra
|
|
526
492
|
}),
|
|
527
493
|
normalizeMessage: (message) => {
|
|
@@ -532,11 +498,7 @@ function createDiscordMessagingActionContext(params) {
|
|
|
532
498
|
}
|
|
533
499
|
//#endregion
|
|
534
500
|
//#region extensions/discord/src/actions/runtime.guild.ts
|
|
535
|
-
const expressionPermissions = [
|
|
536
|
-
PermissionFlagsBits.ManageGuildExpressions,
|
|
537
|
-
PermissionFlagsBits.CreateGuildExpressions,
|
|
538
|
-
PermissionFlagsBits.ManageEmojisAndStickers
|
|
539
|
-
];
|
|
501
|
+
const expressionPermissions = [PermissionFlagsBits.ManageGuildExpressions, PermissionFlagsBits.CreateGuildExpressions];
|
|
540
502
|
const channelGuard = {
|
|
541
503
|
gate: "channels",
|
|
542
504
|
disabledMessage: "Discord channel management is disabled.",
|
|
@@ -547,11 +509,23 @@ const existingChannelGuard = {
|
|
|
547
509
|
permissionScope: "channel"
|
|
548
510
|
};
|
|
549
511
|
const channelPermissionGuard = {
|
|
550
|
-
...
|
|
551
|
-
permissions: [PermissionFlagsBits.ManageRoles]
|
|
552
|
-
|
|
512
|
+
...existingChannelGuard,
|
|
513
|
+
permissions: [PermissionFlagsBits.ManageRoles]
|
|
514
|
+
};
|
|
515
|
+
const roleGuard = {
|
|
516
|
+
gate: "roles",
|
|
517
|
+
defaultEnabled: false,
|
|
518
|
+
disabledMessage: "Discord role changes are disabled.",
|
|
519
|
+
permissions: [PermissionFlagsBits.ManageRoles]
|
|
553
520
|
};
|
|
554
|
-
const
|
|
521
|
+
const guildActionGuards = {
|
|
522
|
+
memberInfo: void 0,
|
|
523
|
+
roleInfo: void 0,
|
|
524
|
+
emojiList: void 0,
|
|
525
|
+
channelInfo: void 0,
|
|
526
|
+
channelList: void 0,
|
|
527
|
+
voiceStatus: void 0,
|
|
528
|
+
eventList: void 0,
|
|
555
529
|
emojiUpload: {
|
|
556
530
|
gate: "emojiUploads",
|
|
557
531
|
disabledMessage: "Discord emoji uploads are disabled.",
|
|
@@ -562,18 +536,8 @@ const guildAdminActionGuards = {
|
|
|
562
536
|
disabledMessage: "Discord sticker uploads are disabled.",
|
|
563
537
|
permissions: expressionPermissions
|
|
564
538
|
},
|
|
565
|
-
roleAdd:
|
|
566
|
-
|
|
567
|
-
defaultEnabled: false,
|
|
568
|
-
disabledMessage: "Discord role changes are disabled.",
|
|
569
|
-
permissions: [PermissionFlagsBits.ManageRoles]
|
|
570
|
-
},
|
|
571
|
-
roleRemove: {
|
|
572
|
-
gate: "roles",
|
|
573
|
-
defaultEnabled: false,
|
|
574
|
-
disabledMessage: "Discord role changes are disabled.",
|
|
575
|
-
permissions: [PermissionFlagsBits.ManageRoles]
|
|
576
|
-
},
|
|
539
|
+
roleAdd: roleGuard,
|
|
540
|
+
roleRemove: roleGuard,
|
|
577
541
|
eventCreate: {
|
|
578
542
|
gate: "events",
|
|
579
543
|
disabledMessage: "Discord events are disabled.",
|
|
@@ -589,14 +553,13 @@ const guildAdminActionGuards = {
|
|
|
589
553
|
channelPermissionSet: channelPermissionGuard,
|
|
590
554
|
channelPermissionRemove: channelPermissionGuard
|
|
591
555
|
};
|
|
556
|
+
function isDiscordGuildAction(action) {
|
|
557
|
+
return Object.hasOwn(guildActionGuards, action);
|
|
558
|
+
}
|
|
592
559
|
function isLockedThreadChannel(channel) {
|
|
593
560
|
if (!channel || typeof channel !== "object") return false;
|
|
594
561
|
return channel.thread_metadata?.locked === true;
|
|
595
562
|
}
|
|
596
|
-
function assertGuildAdminActionEnabled(action, isActionEnabled) {
|
|
597
|
-
const guard = guildAdminActionGuards[action];
|
|
598
|
-
if (guard && !isActionEnabled(guard.gate, guard.defaultEnabled)) throw new Error(guard.disabledMessage);
|
|
599
|
-
}
|
|
600
563
|
async function resolveGuildIdForGuildAdminAction(params) {
|
|
601
564
|
const guildId = readStringParam(params.values, "guildId");
|
|
602
565
|
if (guildId) return guildId;
|
|
@@ -608,10 +571,6 @@ async function resolveGuildIdForGuildAdminAction(params) {
|
|
|
608
571
|
}));
|
|
609
572
|
return "guild_id" in channel ? channel.guild_id ?? void 0 : void 0;
|
|
610
573
|
}
|
|
611
|
-
function readChannelScopedPermissionTargetId(action, values) {
|
|
612
|
-
if (action === "categoryEdit" || action === "categoryDelete") return readStringParam(values, "categoryId");
|
|
613
|
-
return readStringParam(values, "channelId");
|
|
614
|
-
}
|
|
615
574
|
async function resolveGuildAdminActionPermissions(params) {
|
|
616
575
|
if (params.action !== "channelEdit") return params.guard.permissions;
|
|
617
576
|
const channelId = readStringParam(params.values, "channelId");
|
|
@@ -626,7 +585,7 @@ async function resolveGuildAdminActionPermissions(params) {
|
|
|
626
585
|
return edit.archived === false && Object.entries(edit).every(([field, value]) => value === void 0 || field === "channelId" || field === "archived") && !isLockedThreadChannel(channel) ? [PermissionFlagsBits.ManageThreads, PermissionFlagsBits.SendMessages] : [PermissionFlagsBits.ManageThreads];
|
|
627
586
|
}
|
|
628
587
|
async function verifySenderGuildAdminPermission(params) {
|
|
629
|
-
const guard =
|
|
588
|
+
const guard = guildActionGuards[params.action];
|
|
630
589
|
const senderUserId = readStringParam(params.values, "senderUserId");
|
|
631
590
|
if (!guard?.permissions.length || !senderUserId) return;
|
|
632
591
|
const requiredPermissions = await resolveGuildAdminActionPermissions({
|
|
@@ -639,7 +598,7 @@ async function verifySenderGuildAdminPermission(params) {
|
|
|
639
598
|
cfg: params.cfg,
|
|
640
599
|
accountId: params.accountId
|
|
641
600
|
});
|
|
642
|
-
const targetChannelId = guard?.permissionScope === "channel" || params.action === "eventCreate" ?
|
|
601
|
+
const targetChannelId = guard?.permissionScope === "channel" || params.action === "eventCreate" ? readStringParam(params.values, params.action === "categoryEdit" || params.action === "categoryDelete" ? "categoryId" : "channelId") : void 0;
|
|
643
602
|
const hasPermission = targetChannelId ? await hasAnyChannelPermissionDiscord(guildId, targetChannelId, senderUserId, requiredPermissions, actionOptions) : await hasAnyGuildPermissionDiscord(guildId, senderUserId, requiredPermissions, actionOptions);
|
|
644
603
|
const requiresCurrentThreadAccess = params.action === "channelEdit" && requiredPermissions.includes(PermissionFlagsBits.SendMessages);
|
|
645
604
|
if (!hasPermission || requiresCurrentThreadAccess && (!targetChannelId || !await canViewDiscordGuildChannel(guildId, targetChannelId, senderUserId, actionOptions))) throw new Error("Sender does not have required permissions for this guild action.");
|
|
@@ -656,16 +615,14 @@ async function verifySenderGuildAdminPermission(params) {
|
|
|
656
615
|
if (canManageRole === false || targetType === "role" && canManageRole === null) throw new Error("Sender cannot manage the requested role overwrite.");
|
|
657
616
|
}
|
|
658
617
|
}
|
|
659
|
-
function readChannelPermissionTarget(params) {
|
|
660
|
-
return {
|
|
661
|
-
channelId: readStringParam(params, "channelId", { required: true }),
|
|
662
|
-
targetId: readStringParam(params, "targetId", { required: true })
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
618
|
async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, options) {
|
|
666
619
|
const accountId = readStringParam(params, "accountId");
|
|
667
620
|
if (!cfg) throw new Error("Discord guild actions require a resolved runtime config.");
|
|
668
|
-
|
|
621
|
+
const assertActionEnabled = () => {
|
|
622
|
+
const guard = guildActionGuards[action];
|
|
623
|
+
if (guard && !isActionEnabled(guard.gate, guard.defaultEnabled)) throw new Error(guard.disabledMessage);
|
|
624
|
+
};
|
|
625
|
+
assertActionEnabled();
|
|
669
626
|
await verifySenderGuildAdminPermission({
|
|
670
627
|
action,
|
|
671
628
|
values: params,
|
|
@@ -679,30 +636,38 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
679
636
|
cfg,
|
|
680
637
|
options
|
|
681
638
|
});
|
|
682
|
-
const withOpts = (
|
|
639
|
+
const withOpts = () => createDiscordActionOptions({
|
|
683
640
|
cfg,
|
|
684
|
-
accountId
|
|
685
|
-
extra
|
|
641
|
+
accountId
|
|
686
642
|
});
|
|
687
643
|
const mediaPolicyOptions = {
|
|
688
644
|
mediaAccess: options?.mediaAccess,
|
|
689
645
|
mediaLocalRoots: options?.mediaLocalRoots,
|
|
690
646
|
mediaReadFile: options?.mediaReadFile
|
|
691
647
|
};
|
|
692
|
-
const
|
|
648
|
+
const readRequiredString = (key) => readStringParam(params, key, { required: true });
|
|
649
|
+
const readMetadataGuildId = async (guildId = readRequiredString("guildId")) => {
|
|
693
650
|
await readTargetGate.assertGuildReadTargetAllowed({
|
|
694
651
|
guildId,
|
|
695
|
-
filteredResults:
|
|
652
|
+
filteredResults: action === "channelList" ? true : void 0,
|
|
696
653
|
channelTargetRequiredMessage: "Discord guild metadata reads require a wildcard channel allowlist for this guild."
|
|
697
654
|
});
|
|
655
|
+
return guildId;
|
|
698
656
|
};
|
|
699
|
-
|
|
657
|
+
assertActionEnabled();
|
|
700
658
|
switch (action) {
|
|
701
|
-
case "memberInfo":
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
await
|
|
705
|
-
const userId =
|
|
659
|
+
case "memberInfo":
|
|
660
|
+
case "voiceStatus": {
|
|
661
|
+
if (!isActionEnabled(action)) throw new Error(action === "memberInfo" ? "Discord member info is disabled." : "Discord voice status is disabled.");
|
|
662
|
+
const guildId = await readMetadataGuildId();
|
|
663
|
+
const userId = readRequiredString("userId");
|
|
664
|
+
if (action === "voiceStatus") {
|
|
665
|
+
const voice = await fetchVoiceStatusDiscord(guildId, userId, withOpts());
|
|
666
|
+
return jsonResult({
|
|
667
|
+
ok: true,
|
|
668
|
+
voice
|
|
669
|
+
});
|
|
670
|
+
}
|
|
706
671
|
const effectiveAccountId = accountId ?? resolveDefaultDiscordAccountId(cfg);
|
|
707
672
|
const member = await fetchMemberInfoDiscord(guildId, userId, createDiscordActionOptions({
|
|
708
673
|
cfg,
|
|
@@ -724,8 +689,7 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
724
689
|
case "eventList": {
|
|
725
690
|
const roleInfo = action === "roleInfo";
|
|
726
691
|
if (!isActionEnabled(roleInfo ? "roleInfo" : "events")) throw new Error(roleInfo ? "Discord role info is disabled." : "Discord events are disabled.");
|
|
727
|
-
const guildId =
|
|
728
|
-
await assertGuildMetadataReadAllowed(guildId);
|
|
692
|
+
const guildId = await readMetadataGuildId();
|
|
729
693
|
const read = roleInfo ? fetchRoleInfoDiscord : listScheduledEventsDiscord;
|
|
730
694
|
return jsonResult({
|
|
731
695
|
ok: true,
|
|
@@ -740,7 +704,7 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
740
704
|
cfg
|
|
741
705
|
});
|
|
742
706
|
if (!guildId) throw new Error("Discord emoji listing requires guildId or a server channel.");
|
|
743
|
-
await
|
|
707
|
+
await readMetadataGuildId(guildId);
|
|
744
708
|
const limit = Math.min(readPositiveIntegerParam(params, "limit") ?? 100, 100);
|
|
745
709
|
const fetchEmojis = async () => (await listGuildEmojisDiscord(guildId, withOpts())).flatMap(({ name, id, animated }) => name && id ? [{
|
|
746
710
|
name,
|
|
@@ -756,9 +720,9 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
756
720
|
}
|
|
757
721
|
case "emojiUpload": {
|
|
758
722
|
const upload = {
|
|
759
|
-
guildId:
|
|
760
|
-
name:
|
|
761
|
-
mediaUrl:
|
|
723
|
+
guildId: readRequiredString("guildId"),
|
|
724
|
+
name: readRequiredString("name"),
|
|
725
|
+
mediaUrl: readRequiredString("mediaUrl"),
|
|
762
726
|
roleIds: readStringArrayParam(params, "roleIds")
|
|
763
727
|
};
|
|
764
728
|
const emoji = await uploadEmojiDiscord({
|
|
@@ -776,11 +740,11 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
776
740
|
}
|
|
777
741
|
case "stickerUpload": {
|
|
778
742
|
const sticker = await uploadStickerDiscord({
|
|
779
|
-
guildId:
|
|
780
|
-
name:
|
|
781
|
-
description:
|
|
782
|
-
tags:
|
|
783
|
-
mediaUrl:
|
|
743
|
+
guildId: readRequiredString("guildId"),
|
|
744
|
+
name: readRequiredString("name"),
|
|
745
|
+
description: readRequiredString("description"),
|
|
746
|
+
tags: readRequiredString("tags"),
|
|
747
|
+
mediaUrl: readRequiredString("mediaUrl")
|
|
784
748
|
}, createDiscordActionOptions({
|
|
785
749
|
cfg,
|
|
786
750
|
accountId,
|
|
@@ -793,9 +757,9 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
793
757
|
}
|
|
794
758
|
case "roleAdd":
|
|
795
759
|
case "roleRemove": {
|
|
796
|
-
const guildId =
|
|
797
|
-
const userId =
|
|
798
|
-
const roleId =
|
|
760
|
+
const guildId = readRequiredString("guildId");
|
|
761
|
+
const userId = readRequiredString("userId");
|
|
762
|
+
const roleId = readRequiredString("roleId");
|
|
799
763
|
await (action === "roleAdd" ? addRoleDiscord : removeRoleDiscord)({
|
|
800
764
|
guildId,
|
|
801
765
|
userId,
|
|
@@ -803,20 +767,19 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
803
767
|
}, withOpts());
|
|
804
768
|
return jsonResult({ ok: true });
|
|
805
769
|
}
|
|
806
|
-
case "channelInfo":
|
|
807
|
-
if (!isActionEnabled("channelInfo")) throw new Error("Discord channel info is disabled.");
|
|
808
|
-
const channelId = readStringParam(params, "channelId", { required: true });
|
|
809
|
-
await readTargetGate.assertReadTargetAllowed({ channelId });
|
|
810
|
-
const channel = await fetchChannelInfoDiscord(channelId, withOpts());
|
|
811
|
-
return jsonResult({
|
|
812
|
-
ok: true,
|
|
813
|
-
channel
|
|
814
|
-
});
|
|
815
|
-
}
|
|
770
|
+
case "channelInfo":
|
|
816
771
|
case "channelList": {
|
|
817
772
|
if (!isActionEnabled("channelInfo")) throw new Error("Discord channel info is disabled.");
|
|
818
|
-
|
|
819
|
-
|
|
773
|
+
if (action === "channelInfo") {
|
|
774
|
+
const channelId = readRequiredString("channelId");
|
|
775
|
+
await readTargetGate.assertReadTargetAllowed({ channelId });
|
|
776
|
+
const channel = await fetchChannelInfoDiscord(channelId, withOpts());
|
|
777
|
+
return jsonResult({
|
|
778
|
+
ok: true,
|
|
779
|
+
channel
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
const guildId = await readMetadataGuildId();
|
|
820
783
|
const channels = await listGuildChannelsDiscord(guildId, withOpts());
|
|
821
784
|
const visibleChannels = await readTargetGate.filterGuildChannelList({
|
|
822
785
|
guildId,
|
|
@@ -827,21 +790,10 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
827
790
|
channels: visibleChannels
|
|
828
791
|
});
|
|
829
792
|
}
|
|
830
|
-
case "voiceStatus": {
|
|
831
|
-
if (!isActionEnabled("voiceStatus")) throw new Error("Discord voice status is disabled.");
|
|
832
|
-
const guildId = readStringParam(params, "guildId", { required: true });
|
|
833
|
-
await assertGuildMetadataReadAllowed(guildId);
|
|
834
|
-
const userId = readStringParam(params, "userId", { required: true });
|
|
835
|
-
const voice = await fetchVoiceStatusDiscord(guildId, userId, withOpts());
|
|
836
|
-
return jsonResult({
|
|
837
|
-
ok: true,
|
|
838
|
-
voice
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
793
|
case "eventCreate": {
|
|
842
|
-
const guildId =
|
|
843
|
-
const name =
|
|
844
|
-
const startTime =
|
|
794
|
+
const guildId = readRequiredString("guildId");
|
|
795
|
+
const name = readRequiredString("name");
|
|
796
|
+
const startTime = readRequiredString("startTime");
|
|
845
797
|
const endTime = readStringParam(params, "endTime");
|
|
846
798
|
const description = readStringParam(params, "description");
|
|
847
799
|
const channelId = readStringParam(params, "channelId");
|
|
@@ -869,8 +821,8 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
869
821
|
case "categoryCreate":
|
|
870
822
|
case "channelCreate": {
|
|
871
823
|
const channel = await createChannelDiscord(action === "categoryCreate" ? {
|
|
872
|
-
guildId:
|
|
873
|
-
name:
|
|
824
|
+
guildId: readRequiredString("guildId"),
|
|
825
|
+
name: readRequiredString("name"),
|
|
874
826
|
type: 4,
|
|
875
827
|
position: readNonNegativeIntegerParam(params, "position")
|
|
876
828
|
} : readDiscordChannelCreateParams(params), withOpts());
|
|
@@ -882,7 +834,7 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
882
834
|
case "categoryEdit":
|
|
883
835
|
case "channelEdit": {
|
|
884
836
|
const channel = await editChannelDiscord(action === "categoryEdit" ? {
|
|
885
|
-
channelId:
|
|
837
|
+
channelId: readRequiredString("categoryId"),
|
|
886
838
|
name: readStringParam(params, "name"),
|
|
887
839
|
position: readNonNegativeIntegerParam(params, "position")
|
|
888
840
|
} : readDiscordChannelEditParams(params), withOpts());
|
|
@@ -893,16 +845,22 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
893
845
|
}
|
|
894
846
|
case "categoryDelete":
|
|
895
847
|
case "channelDelete": {
|
|
896
|
-
const channelId =
|
|
848
|
+
const channelId = readRequiredString(action === "categoryDelete" ? "categoryId" : "channelId");
|
|
897
849
|
const result = await deleteChannelDiscord(channelId, withOpts());
|
|
898
850
|
return jsonResult(result);
|
|
899
851
|
}
|
|
900
852
|
case "channelMove":
|
|
901
853
|
await moveChannelDiscord(readDiscordChannelMoveParams(params), withOpts());
|
|
902
854
|
return jsonResult({ ok: true });
|
|
903
|
-
case "channelPermissionSet":
|
|
904
|
-
|
|
905
|
-
const
|
|
855
|
+
case "channelPermissionSet":
|
|
856
|
+
case "channelPermissionRemove": {
|
|
857
|
+
const channelId = readRequiredString("channelId");
|
|
858
|
+
const targetId = readRequiredString("targetId");
|
|
859
|
+
if (action === "channelPermissionRemove") {
|
|
860
|
+
await removeChannelPermissionDiscord(channelId, targetId, withOpts());
|
|
861
|
+
return jsonResult({ ok: true });
|
|
862
|
+
}
|
|
863
|
+
const targetType = readRequiredString("targetType") === "member" ? 1 : 0;
|
|
906
864
|
const allow = readStringParam(params, "allow");
|
|
907
865
|
const deny = readStringParam(params, "deny");
|
|
908
866
|
await setChannelPermissionDiscord({
|
|
@@ -914,11 +872,6 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
914
872
|
}, withOpts());
|
|
915
873
|
return jsonResult({ ok: true });
|
|
916
874
|
}
|
|
917
|
-
case "channelPermissionRemove": {
|
|
918
|
-
const { channelId, targetId } = readChannelPermissionTarget(params);
|
|
919
|
-
await removeChannelPermissionDiscord(channelId, targetId, withOpts());
|
|
920
|
-
return jsonResult({ ok: true });
|
|
921
|
-
}
|
|
922
875
|
default: throw new Error(`Unknown action: ${action}`);
|
|
923
876
|
}
|
|
924
877
|
}
|
|
@@ -935,14 +888,17 @@ function parseDiscordMessageLink(link) {
|
|
|
935
888
|
}
|
|
936
889
|
async function handleDiscordMessageManagementAction(ctx) {
|
|
937
890
|
switch (ctx.action) {
|
|
938
|
-
case "permissions":
|
|
939
|
-
|
|
891
|
+
case "permissions":
|
|
892
|
+
case "listPins": {
|
|
893
|
+
const permissions = ctx.action === "permissions";
|
|
894
|
+
const gate = permissions ? "permissions" : "pins";
|
|
895
|
+
if (!ctx.isActionEnabled(gate)) throw new Error(`Discord ${gate} are disabled.`);
|
|
940
896
|
const channelId = ctx.resolveChannelId();
|
|
941
897
|
await ctx.assertReadTargetAllowed({ channelId });
|
|
942
|
-
const
|
|
898
|
+
const value = permissions ? await fetchChannelPermissionsDiscord(channelId, ctx.withOpts()) : (await listPinsDiscord(channelId, ctx.withOpts())).map((pin) => ctx.normalizeMessage(pin));
|
|
943
899
|
return jsonResult({
|
|
944
900
|
ok: true,
|
|
945
|
-
|
|
901
|
+
[gate]: value
|
|
946
902
|
});
|
|
947
903
|
}
|
|
948
904
|
case "fetchMessage": {
|
|
@@ -951,12 +907,7 @@ async function handleDiscordMessageManagementAction(ctx) {
|
|
|
951
907
|
let guildId = readStringParam(ctx.params, "guildId");
|
|
952
908
|
let channelId = readStringParam(ctx.params, "channelId");
|
|
953
909
|
let messageId = readStringParam(ctx.params, "messageId");
|
|
954
|
-
if (messageLink) {
|
|
955
|
-
const parsed = parseDiscordMessageLink(messageLink);
|
|
956
|
-
guildId = parsed.guildId;
|
|
957
|
-
channelId = parsed.channelId;
|
|
958
|
-
messageId = parsed.messageId;
|
|
959
|
-
}
|
|
910
|
+
if (messageLink) ({guildId, channelId, messageId} = parseDiscordMessageLink(messageLink));
|
|
960
911
|
if (!guildId || !channelId || !messageId) throw new Error("Discord message fetch requires guildId, channelId, and messageId (or a valid messageLink).");
|
|
961
912
|
await ctx.assertReadTargetAllowed({
|
|
962
913
|
guildId,
|
|
@@ -999,7 +950,8 @@ async function handleDiscordMessageManagementAction(ctx) {
|
|
|
999
950
|
mode: "progress",
|
|
1000
951
|
active: true,
|
|
1001
952
|
seed: `${ctx.accountId}:${channelId}`,
|
|
1002
|
-
initialSnapshot: snapshot
|
|
953
|
+
initialSnapshot: snapshot,
|
|
954
|
+
toolIcons: true
|
|
1003
955
|
}).getText(), {
|
|
1004
956
|
maxChars: Math.min(ctx.accountConfig.textChunkLimit ?? 2e3, 2e3),
|
|
1005
957
|
maxLinesPerMessage: Number.MAX_SAFE_INTEGER
|
|
@@ -1029,16 +981,6 @@ async function handleDiscordMessageManagementAction(ctx) {
|
|
|
1029
981
|
await (deleting ? deleteMessageDiscord : ctx.action === "pinMessage" ? pinMessageDiscord : unpinMessageDiscord)(channelId, messageId, ctx.withOpts());
|
|
1030
982
|
return jsonResult({ ok: true });
|
|
1031
983
|
}
|
|
1032
|
-
case "listPins": {
|
|
1033
|
-
if (!ctx.isActionEnabled("pins")) throw new Error("Discord pins are disabled.");
|
|
1034
|
-
const channelId = ctx.resolveChannelId();
|
|
1035
|
-
await ctx.assertReadTargetAllowed({ channelId });
|
|
1036
|
-
const pins = await listPinsDiscord(channelId, ctx.withOpts());
|
|
1037
|
-
return jsonResult({
|
|
1038
|
-
ok: true,
|
|
1039
|
-
pins: pins.map((pin) => ctx.normalizeMessage(pin))
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
984
|
case "searchMessages": {
|
|
1043
985
|
if (!ctx.isActionEnabled("search")) throw new Error("Discord search is disabled.");
|
|
1044
986
|
let guildId = readStringParam(ctx.params, "guildId");
|
|
@@ -1091,40 +1033,34 @@ async function handleDiscordMessageManagementAction(ctx) {
|
|
|
1091
1033
|
//#endregion
|
|
1092
1034
|
//#region extensions/discord/src/actions/runtime.messaging.reactions.ts
|
|
1093
1035
|
async function handleDiscordReactionMessagingAction(ctx) {
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
const channelId = await ctx.resolveReactionChannelId();
|
|
1117
|
-
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
1118
|
-
const limit = readPositiveIntegerParam(ctx.params, "limit");
|
|
1119
|
-
await ctx.assertReadTargetAllowed({ channelId });
|
|
1120
|
-
const reactions = await fetchReactionsDiscord(channelId, messageId, ctx.withReactionRuntimeOptions({ limit }));
|
|
1121
|
-
return jsonResult({
|
|
1122
|
-
ok: true,
|
|
1123
|
-
reactions
|
|
1124
|
-
});
|
|
1125
|
-
}
|
|
1126
|
-
default: return;
|
|
1036
|
+
const action = ctx.action;
|
|
1037
|
+
if (action !== "react" && action !== "reactions") return;
|
|
1038
|
+
if (!ctx.isActionEnabled("reactions")) throw new Error("Discord reactions are disabled.");
|
|
1039
|
+
const channelId = await ctx.resolveReactionChannelId();
|
|
1040
|
+
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
1041
|
+
if (action === "reactions") {
|
|
1042
|
+
const limit = readPositiveIntegerParam(ctx.params, "limit");
|
|
1043
|
+
await ctx.assertReadTargetAllowed({ channelId });
|
|
1044
|
+
const reactions = await fetchReactionsDiscord(channelId, messageId, ctx.withReactionRuntimeOptions({ limit }));
|
|
1045
|
+
return jsonResult({
|
|
1046
|
+
ok: true,
|
|
1047
|
+
reactions
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
const { emoji, remove, isEmpty } = readReactionParams(ctx.params, { removeErrorMessage: "Emoji is required to remove a Discord reaction." });
|
|
1051
|
+
await ctx.assertReadTargetAllowed({ channelId });
|
|
1052
|
+
if (isEmpty) {
|
|
1053
|
+
const removed = await removeOwnReactionsDiscord(channelId, messageId, ctx.withReactionRuntimeOptions());
|
|
1054
|
+
return jsonResult({
|
|
1055
|
+
ok: true,
|
|
1056
|
+
removed: removed.removed
|
|
1057
|
+
});
|
|
1127
1058
|
}
|
|
1059
|
+
await (remove ? removeReactionDiscord : reactMessageDiscord)(channelId, messageId, emoji, ctx.withReactionRuntimeOptions());
|
|
1060
|
+
return jsonResult({
|
|
1061
|
+
ok: true,
|
|
1062
|
+
[remove ? "removed" : "added"]: emoji
|
|
1063
|
+
});
|
|
1128
1064
|
}
|
|
1129
1065
|
//#endregion
|
|
1130
1066
|
//#region extensions/discord/src/actions/runtime.messaging.send.ts
|
|
@@ -1136,15 +1072,12 @@ function resolveActionReplyReference(ctx, replyToId) {
|
|
|
1136
1072
|
replyToMode: reply.source === "implicit" ? reply.mode : void 0
|
|
1137
1073
|
}) : createReusableDiscordReplyReference(replyToId);
|
|
1138
1074
|
}
|
|
1139
|
-
function readDiscordThreadArchiveTimestamp(thread) {
|
|
1140
|
-
const archiveTimestamp = asOptionalRecord(asOptionalRecord(thread)?.thread_metadata)?.archive_timestamp;
|
|
1141
|
-
return typeof archiveTimestamp === "string" && archiveTimestamp.trim() ? archiveTimestamp : void 0;
|
|
1142
|
-
}
|
|
1143
1075
|
function normalizeDiscordThreadListActionResult(params) {
|
|
1144
1076
|
const record = asOptionalRecord(params.value);
|
|
1145
1077
|
const threadItems = Array.isArray(record?.threads) ? record.threads : [];
|
|
1146
1078
|
const hasMore = record?.has_more === true;
|
|
1147
|
-
const
|
|
1079
|
+
const archiveTimestamp = params.includeArchived && hasMore ? asOptionalRecord(asOptionalRecord(threadItems[threadItems.length - 1])?.thread_metadata)?.archive_timestamp : void 0;
|
|
1080
|
+
const nextBefore = typeof archiveTimestamp === "string" && archiveTimestamp.trim() ? archiveTimestamp : void 0;
|
|
1148
1081
|
return {
|
|
1149
1082
|
ok: true,
|
|
1150
1083
|
threads: params.value,
|
|
@@ -1163,27 +1096,22 @@ function normalizeDiscordThreadListActionResult(params) {
|
|
|
1163
1096
|
};
|
|
1164
1097
|
}
|
|
1165
1098
|
async function appendDiscordThreadRenameResult(ctx, params) {
|
|
1166
|
-
const threadName = params.threadName
|
|
1099
|
+
const threadName = params.threadName;
|
|
1167
1100
|
if (!threadName) return params.payload;
|
|
1168
|
-
|
|
1101
|
+
const ignored = (reason) => ({
|
|
1169
1102
|
...params.payload,
|
|
1170
|
-
warning:
|
|
1171
|
-
};
|
|
1103
|
+
warning: `Discord threadName was ignored because ${reason}.`
|
|
1104
|
+
});
|
|
1105
|
+
if (!ctx.isActionEnabled("channels")) return ignored("Discord channel management is disabled");
|
|
1172
1106
|
let channelId;
|
|
1173
1107
|
try {
|
|
1174
1108
|
channelId = resolveDiscordChannelId(params.target);
|
|
1175
1109
|
} catch {
|
|
1176
|
-
return
|
|
1177
|
-
...params.payload,
|
|
1178
|
-
warning: "Discord threadName was ignored because the send target is not a channel/thread."
|
|
1179
|
-
};
|
|
1110
|
+
return ignored("the send target is not a channel/thread");
|
|
1180
1111
|
}
|
|
1181
1112
|
try {
|
|
1182
1113
|
const channel = await fetchChannelInfoDiscord(channelId, ctx.withOpts());
|
|
1183
|
-
if (!isDiscordThreadChannelType(channel.type)) return
|
|
1184
|
-
...params.payload,
|
|
1185
|
-
warning: "Discord threadName was ignored because the send target is not a thread."
|
|
1186
|
-
};
|
|
1114
|
+
if (!isDiscordThreadChannelType(channel.type)) return ignored("the send target is not a thread");
|
|
1187
1115
|
const renamed = await editChannelDiscord({
|
|
1188
1116
|
channelId,
|
|
1189
1117
|
name: threadName
|
|
@@ -1348,13 +1276,14 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1348
1276
|
guildId,
|
|
1349
1277
|
channelTargetRequiredMessage: "Discord active thread lists require a wildcard channel allowlist so each read target can be authorized."
|
|
1350
1278
|
});
|
|
1351
|
-
const
|
|
1279
|
+
const query = {
|
|
1352
1280
|
guildId,
|
|
1353
1281
|
channelId,
|
|
1354
1282
|
includeArchived,
|
|
1355
1283
|
before,
|
|
1356
1284
|
limit
|
|
1357
|
-
}
|
|
1285
|
+
};
|
|
1286
|
+
const response = await listThreadsDiscord(query, ctx.withOpts());
|
|
1358
1287
|
const threads = channelId && includeArchived !== true ? await ctx.filterActiveThreadList({
|
|
1359
1288
|
guildId,
|
|
1360
1289
|
channelId,
|
|
@@ -1362,11 +1291,8 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1362
1291
|
}) : response;
|
|
1363
1292
|
return jsonResult(normalizeDiscordThreadListActionResult({
|
|
1364
1293
|
value: threads,
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
includeArchived: includeArchived === true,
|
|
1368
|
-
before,
|
|
1369
|
-
limit
|
|
1294
|
+
...query,
|
|
1295
|
+
includeArchived: includeArchived === true
|
|
1370
1296
|
}));
|
|
1371
1297
|
}
|
|
1372
1298
|
case "threadReply": {
|
|
@@ -1406,9 +1332,9 @@ async function handleDiscordMessagingAction(action, params, isActionEnabled, cfg
|
|
|
1406
1332
|
cfg,
|
|
1407
1333
|
options
|
|
1408
1334
|
});
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1335
|
+
const result = await handleDiscordReactionMessagingAction(ctx) ?? await handleDiscordMessageSendAction(ctx) ?? await handleDiscordMessageManagementAction(ctx);
|
|
1336
|
+
if (result == null) throw new Error(`Unknown action: ${action}`);
|
|
1337
|
+
return result;
|
|
1412
1338
|
}
|
|
1413
1339
|
//#endregion
|
|
1414
1340
|
//#region extensions/discord/src/actions/runtime.moderation-shared.ts
|
|
@@ -1418,7 +1344,7 @@ const moderationPermissions = {
|
|
|
1418
1344
|
ban: PermissionFlagsBits.BanMembers
|
|
1419
1345
|
};
|
|
1420
1346
|
function isDiscordModerationAction(action) {
|
|
1421
|
-
return
|
|
1347
|
+
return Object.hasOwn(moderationPermissions, action);
|
|
1422
1348
|
}
|
|
1423
1349
|
function requiredGuildPermissionForModerationAction(action) {
|
|
1424
1350
|
return moderationPermissions[action];
|
|
@@ -1440,13 +1366,6 @@ function readDiscordModerationCommand(action, params) {
|
|
|
1440
1366
|
}
|
|
1441
1367
|
//#endregion
|
|
1442
1368
|
//#region extensions/discord/src/actions/runtime.moderation.ts
|
|
1443
|
-
async function verifySenderModerationPermission(params) {
|
|
1444
|
-
if (!params.senderUserId) return;
|
|
1445
|
-
if (!await hasAnyGuildPermissionDiscord(params.guildId, params.senderUserId, [params.requiredPermission], createDiscordActionOptions({
|
|
1446
|
-
cfg: params.cfg,
|
|
1447
|
-
accountId: params.accountId
|
|
1448
|
-
}))) throw new Error("Sender does not have required permissions for this moderation action.");
|
|
1449
|
-
}
|
|
1450
1369
|
async function handleDiscordModerationAction(action, params, isActionEnabled, cfg) {
|
|
1451
1370
|
if (!isDiscordModerationAction(action)) throw new Error(`Unknown action: ${action}`);
|
|
1452
1371
|
if (!isActionEnabled("moderation", false)) throw new Error("Discord moderation is disabled.");
|
|
@@ -1458,13 +1377,7 @@ async function handleDiscordModerationAction(action, params, isActionEnabled, cf
|
|
|
1458
1377
|
cfg,
|
|
1459
1378
|
accountId
|
|
1460
1379
|
});
|
|
1461
|
-
await
|
|
1462
|
-
guildId: command.guildId,
|
|
1463
|
-
senderUserId,
|
|
1464
|
-
requiredPermission: requiredGuildPermissionForModerationAction(command.action),
|
|
1465
|
-
accountId,
|
|
1466
|
-
cfg
|
|
1467
|
-
});
|
|
1380
|
+
if (!await (senderUserId ? hasAnyGuildPermissionDiscord(command.guildId, senderUserId, [requiredGuildPermissionForModerationAction(command.action)], withOpts()) : true)) throw new Error("Sender does not have required permissions for this moderation action.");
|
|
1468
1381
|
const target = {
|
|
1469
1382
|
guildId: command.guildId,
|
|
1470
1383
|
userId: command.userId,
|
|
@@ -1536,13 +1449,12 @@ async function handleDiscordPresenceAction(action, params, isActionEnabled, cfg)
|
|
|
1536
1449
|
if (state) activity.state = state;
|
|
1537
1450
|
activities.push(activity);
|
|
1538
1451
|
}
|
|
1539
|
-
|
|
1452
|
+
gateway.updatePresence({
|
|
1540
1453
|
since: null,
|
|
1541
1454
|
activities,
|
|
1542
1455
|
status,
|
|
1543
1456
|
afk: false
|
|
1544
|
-
};
|
|
1545
|
-
gateway.updatePresence(presenceData);
|
|
1457
|
+
});
|
|
1546
1458
|
return jsonResult({
|
|
1547
1459
|
ok: true,
|
|
1548
1460
|
status,
|
|
@@ -1573,29 +1485,6 @@ const messagingActions = /* @__PURE__ */ new Set([
|
|
|
1573
1485
|
"listPins",
|
|
1574
1486
|
"searchMessages"
|
|
1575
1487
|
]);
|
|
1576
|
-
const guildActions = /* @__PURE__ */ new Set([
|
|
1577
|
-
"memberInfo",
|
|
1578
|
-
"roleInfo",
|
|
1579
|
-
"emojiList",
|
|
1580
|
-
"emojiUpload",
|
|
1581
|
-
"stickerUpload",
|
|
1582
|
-
"roleAdd",
|
|
1583
|
-
"roleRemove",
|
|
1584
|
-
"channelInfo",
|
|
1585
|
-
"channelList",
|
|
1586
|
-
"voiceStatus",
|
|
1587
|
-
"eventList",
|
|
1588
|
-
"eventCreate",
|
|
1589
|
-
"channelCreate",
|
|
1590
|
-
"channelEdit",
|
|
1591
|
-
"channelDelete",
|
|
1592
|
-
"channelMove",
|
|
1593
|
-
"categoryCreate",
|
|
1594
|
-
"categoryEdit",
|
|
1595
|
-
"categoryDelete",
|
|
1596
|
-
"channelPermissionSet",
|
|
1597
|
-
"channelPermissionRemove"
|
|
1598
|
-
]);
|
|
1599
1488
|
async function handleDiscordAction(params, cfg, options) {
|
|
1600
1489
|
const action = readStringParam(params, "action", { required: true });
|
|
1601
1490
|
const accountId = readStringParam(params, "accountId");
|
|
@@ -1604,7 +1493,7 @@ async function handleDiscordAction(params, cfg, options) {
|
|
|
1604
1493
|
accountId
|
|
1605
1494
|
});
|
|
1606
1495
|
if (messagingActions.has(action)) return await handleDiscordMessagingAction(action, params, isActionEnabled, cfg, options);
|
|
1607
|
-
if (
|
|
1496
|
+
if (isDiscordGuildAction(action)) return await handleDiscordGuildAction(action, params, isActionEnabled, cfg, options);
|
|
1608
1497
|
if (isDiscordModerationAction(action)) return await handleDiscordModerationAction(action, params, isActionEnabled, cfg);
|
|
1609
1498
|
if (action === "setPresence") return await handleDiscordPresenceAction(action, params, isActionEnabled, cfg);
|
|
1610
1499
|
throw new Error(`Unknown action: ${action}`);
|