@openclaw/discord 2026.7.2-beta.7 → 2026.8.1-beta.3
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/{account-inspect-SXiCBCgP.js → account-inspect-D5xmUpnj.js} +49 -43
- package/dist/account-inspect-api.js +1 -1
- package/dist/accounts-DNl-oCEw.js +371 -0
- package/dist/action-runtime-api.js +1 -1
- package/dist/{active-turn-thread-route-MlKWp8RD.js → active-turn-thread-route-fmHl1HNd.js} +9 -11
- package/dist/{activities-api-DTKsuDxf.js → activities-api-KCBAmWxD.js} +133 -175
- package/dist/activities-api.js +1 -1
- package/dist/{allow-list-DzKrtfah.js → allow-list-BDMimASD.js} +2 -3
- package/dist/{api-DnrK9gML.js → api-DNVbJyEy.js} +7 -2
- package/dist/api.js +18 -18
- package/dist/{approval-handler.runtime-HymvFTYn.js → approval-handler.runtime-B12RCYr8.js} +6 -6
- package/dist/{approval-message-safety-DEyKVsAw.js → approval-message-safety-XGFPbDoI.js} +89 -3
- package/dist/{audit-CjsrabP8.js → audit-Yc7eZDd6.js} +5 -5
- package/dist/{channel-actions-uXFTJX3o.js → channel-actions-Dr2QI8Bf.js} +11 -7
- package/dist/{channel-actions.runtime-CIYU90sl.js → channel-actions.runtime-CODTvo7c.js} +99 -97
- package/dist/{channel-vKa-76xY.js → channel-cXYzGc4L.js} +102 -104
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-CmcwZ_qd.js → channel.setup-CSiwnMgs.js} +16 -54
- package/dist/{outbound-session-route-H-HoyH5U.js → components-ezGKo_Yh.js} +69 -142
- package/dist/{config-schema-WHRQcY19.js → config-schema-DC5kDtQ5.js} +42 -11
- package/dist/conversation-binding-route-D6rCQ5S0.js +43 -0
- package/dist/{directory-config-D_LojtCe.js → directory-config-XyCfoqLg.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-Bw5Ephzv.js → directory-live-Df0NbFJB.js} +7 -4
- package/dist/{doctor-Bc4S1qyd.js → doctor-DYY31GrO.js} +34 -13
- package/dist/{doctor-contract-CCFMIDk9.js → doctor-contract-DsWvKIXF.js} +2 -3
- package/dist/doctor-contract-api.js +147 -2
- package/dist/{handle-action.guild-admin-D6VRRW-C.js → handle-action.guild-admin-6Tvvinsa.js} +4 -7
- package/dist/{inbound-event-delivery-CEPlt2uz.js → inbound-event-delivery-De2qxTrP.js} +4 -25
- package/dist/index.js +5 -4
- package/dist/{message-handler-CeiSulIw.js → message-handler-B61q5MOF.js} +118 -33
- package/dist/{message-handler.preflight-DibgQFf2.js → message-handler.preflight-Bzg_Hawz.js} +75 -61
- package/dist/{message-handler.process-Dnc_oz9y.js → message-handler.process--4_712Ec.js} +236 -296
- package/dist/{message-utils-BgTwT_q7.js → message-utils-BXLLnFl6.js} +34 -35
- package/dist/{model-picker-preference-primitives-D25pnCOu.js → model-picker-preference-primitives-BHT1LkR_.js} +3 -3
- package/dist/{outbound-adapter-DtE-i2OJ.js → outbound-adapter-DxHTOqiN.js} +157 -68
- package/dist/{outbound-components-C7GVyfPh.js → outbound-components-B2PL0ooH.js} +3 -3
- package/dist/owner-access-Bg41VzAf.js +107 -0
- package/dist/{pluralkit-CD4B11JB.js → pluralkit-dUl4v1X3.js} +1 -1
- package/dist/{preflight-audio-BjnQZ5yS.js → preflight-audio-DrnqFA8U.js} +22 -28
- package/dist/{probe-BeWKhjqX.js → probe-BTdtVRwU.js} +37 -13
- package/dist/probe.runtime-Dq5-PRKT.js +2 -0
- package/dist/{provider-DfQJX3z5.js → provider-DlK_ynqt.js} +1131 -2021
- package/dist/{provider-session.runtime-Bo88k0pV.js → provider-session.runtime-CvvphHvs.js} +3 -3
- package/dist/provider.runtime-CzKGRiAF.js +2 -0
- package/dist/realtime-session.runtime-ysbMG8v7.js +1351 -0
- package/dist/{resolve-allowlist-common-DHERApxi.js → resolve-allowlist-common-DIVXbD1P.js} +3 -3
- package/dist/{resolve-channels-BjepAj8b.js → resolve-channels-CGeUoIqb.js} +4 -4
- package/dist/{resolve-users-Bc28htgt.js → resolve-users-BtKxLUZv.js} +3 -3
- package/dist/{chunk-DX4jpFQP.js → retry-DNsVTeTo.js} +308 -131
- package/dist/{runtime-BmW_j_hl.js → runtime-CQovMsH3.js} +12 -15
- package/dist/{runtime-_aRC6V2s.js → runtime-D71_VFLr.js} +49 -58
- package/dist/runtime-api.actions.js +2 -2
- package/dist/runtime-api.js +23 -23
- package/dist/runtime-api.lookup.js +5 -5
- package/dist/runtime-api.monitor-CzeTYF32.js +6 -0
- package/dist/runtime-api.monitor.js +6 -5
- package/dist/runtime-api.send.js +6 -6
- package/dist/runtime-api.threads.js +5 -6
- package/dist/sdk-runtime-37OU6_Yh.js +369 -0
- package/dist/{secret-config-contract-B1akrlyY.js → secret-config-contract-B3i6WxV5.js} +53 -25
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/{security-audit.runtime-CPN0xFYz.js → security-audit.runtime-BVKF9VtY.js} +1 -1
- package/dist/{send-CdkZ6zeW.js → send-rQIffSYu.js} +180 -91
- package/dist/{send.components-5uqwkjgE.js → send.components-ChK1wS7w.js} +32 -46
- package/dist/{send.outbound-D-80Ej-t.js → send.outbound-HIkgji_7.js} +57 -34
- package/dist/{send.reactions-CtlmGd_o.js → send.reactions-gmJ6yFPo.js} +14 -21
- package/dist/{send.receipt-CuwRrpFz.js → send.receipt-Cnhoautb.js} +29 -1
- package/dist/{send.shared-jpvAG_u6.js → send.shared-B3fpaLWJ.js} +112 -181
- package/dist/{sender-identity-mG_zsdox.js → sender-identity-BJtfyise.js} +1 -1
- package/dist/setup-entry.js +0 -5
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-CXF1tup1.js → shared-CaAaoksy.js} +27 -23
- package/dist/subagent-hooks-CNT2ZJTJ.js +49 -0
- package/dist/subagent-hooks-api.js +2 -6
- package/dist/subagent-progress-FPLqBY1s.js +110 -0
- package/dist/{system-events-DdUqf91B.js → system-events-Nuwoq_au.js} +2 -2
- package/dist/{target-resolver-C3s_2m0t.js → target-resolver-DIXShHaZ.js} +3 -3
- package/dist/targets-B2pf49zc.js +3 -0
- package/dist/{thread-bindings-C-M-ly7P.js → thread-bindings-VlymUnbz.js} +29 -28
- package/dist/{thread-bindings.manager-DYvSlrva.js → thread-bindings.manager-CngsgErq.js} +258 -29
- package/dist/{thread-bindings.session-updates-DAIlp7Px.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
- package/dist/{thread-bindings.state-Cgi5uRn-.js → thread-bindings.state-D8OMdk4O.js} +3 -16
- package/dist/threading-DU6pgeGm.js +456 -0
- package/dist/transcripts-source-DeIMNbRh.js +265 -0
- package/dist/transcripts-source-api.js +7 -2
- package/dist/{typing--Mzo2kM7.js → typing-oLiS5Z13.js} +1 -1
- package/dist/voice-runtime-CjNFaynA.js +2549 -0
- package/openclaw.plugin.json +215 -25
- package/package.json +15 -11
- package/skills/discord/SKILL.md +22 -115
- package/dist/accounts-DJTf1LtA.js +0 -219
- package/dist/channel-api-CAJ0wMoV.js +0 -21
- package/dist/legacy-state-migrations-api.js +0 -138
- package/dist/manager.runtime-Bjav3pfC.js +0 -3655
- package/dist/preflight-audio.runtime-CoCXMM8r.js +0 -7
- package/dist/probe.runtime-DqFGFMbZ.js +0 -2
- package/dist/provider.runtime-Cy7XZmyh.js +0 -2
- package/dist/runtime-api.monitor-CCRubd3-.js +0 -5
- package/dist/session-binding-contract-api.js +0 -2
- package/dist/subagent-hooks-Dxy7Fmnq.js +0 -120
- package/dist/subagent-progress-DI3sYLLo.js +0 -664
- package/dist/targets-Dv_RN7vT.js +0 -3
- package/dist/thread-bindings.discord-api-BoDNqamb.js +0 -246
- package/dist/transcripts-source-DIKGsTGT.js +0 -123
- package/node_modules/p-map/index.d.ts +0 -155
- package/node_modules/p-map/index.js +0 -285
- package/node_modules/p-map/license +0 -9
- package/node_modules/p-map/package.json +0 -57
- package/node_modules/p-map/readme.md +0 -190
- package/dist/{audit-core-xwjIczO0.js → audit-core-BCX8UeFH.js} +1 -1
- package/dist/{security-audit-jGnJF__m.js → security-audit-BfJhAXZp.js} +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as createDiscordSendResult } from "./send.receipt-
|
|
6
|
-
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
1
|
+
import { o as createReusableDiscordReplyReference, vt as createChannelMessage, yt as createThread } from "./retry-DNsVTeTo.js";
|
|
2
|
+
import { c as resolveDiscordAccount } from "./accounts-DNl-oCEw.js";
|
|
3
|
+
import { i as normalizeDiscordHandleKey, o as resolveDiscordDirectoryUserId } from "./directory-live-Df0NbFJB.js";
|
|
4
|
+
import { A as resolveDiscordMessageFlags, M as resolveDiscordSendEmbeds, N as resolveDiscordSuppressEmbeds, O as buildDiscordMessageRequest, P as createDiscordClient, a as normalizeDiscordPollInput, c as normalizeStickerIds, f as sendDiscordMedia, j as resolveDiscordSendComponents, k as createDiscordMessageNonce, l as resolveChannelId, n as buildDiscordTextChunks, p as sendDiscordText, q as parseAndResolveChannelRecipient, t as buildDiscordSendError, u as resolveDiscordChannel } from "./send.shared-B3fpaLWJ.js";
|
|
5
|
+
import { n as createDiscordSendReceiptFromResults, r as createDiscordSendResult } from "./send.receipt-Cnhoautb.js";
|
|
7
6
|
import { ChannelType } from "discord-api-types/v10";
|
|
8
7
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
9
|
-
import {
|
|
8
|
+
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
9
|
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
11
10
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
11
|
+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
12
12
|
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
13
13
|
import { resolveChunkMode } from "openclaw/plugin-sdk/reply-chunking";
|
|
14
14
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
@@ -416,6 +416,8 @@ function discordTextHasBroadcastMention(text) {
|
|
|
416
416
|
//#endregion
|
|
417
417
|
//#region extensions/discord/src/send.outbound.ts
|
|
418
418
|
const DEFAULT_DISCORD_MEDIA_MAX_MB = 100;
|
|
419
|
+
/** Discord's ChannelFlags.RequireTag is bit 4 on forum/media parent channels. */
|
|
420
|
+
const DISCORD_FORUM_REQUIRE_TAG_FLAG = 16;
|
|
419
421
|
async function sendDiscordThreadTextChunks(params) {
|
|
420
422
|
for (const chunk of params.chunks) await sendDiscordText({
|
|
421
423
|
rest: params.rest,
|
|
@@ -428,12 +430,10 @@ async function sendDiscordThreadTextChunks(params) {
|
|
|
428
430
|
suppressEmbeds: params.suppressEmbeds,
|
|
429
431
|
allowedMentions: params.allowedMentions,
|
|
430
432
|
maxChars: params.maxChars,
|
|
431
|
-
onResult: params.onResult
|
|
433
|
+
onResult: params.onResult,
|
|
434
|
+
onPlatformSendDispatch: params.onPlatformSendDispatch
|
|
432
435
|
});
|
|
433
436
|
}
|
|
434
|
-
function resolveDiscordSuppressEmbeds(params) {
|
|
435
|
-
return params.override ?? params.configured ?? true;
|
|
436
|
-
}
|
|
437
437
|
/** Discord thread names are capped at 100 characters. */
|
|
438
438
|
const DISCORD_THREAD_NAME_LIMIT = 100;
|
|
439
439
|
/** Derive a thread title from the first non-empty line of the message text. */
|
|
@@ -499,6 +499,7 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
499
499
|
const { channelId } = await resolveChannelId(rest, await parseAndResolveChannelRecipient(to, cfg, opts.accountId), request);
|
|
500
500
|
const channel = await resolveDiscordChannel(rest, channelId);
|
|
501
501
|
if (isForumLikeChannel(channel)) {
|
|
502
|
+
if (((channel.flags ?? 0) & DISCORD_FORUM_REQUIRE_TAG_FLAG) !== 0) throw new Error(`Discord forum channel ${channelId} requires an applied tag; use thread-create with appliedTags, then send to the created thread.`);
|
|
502
503
|
const threadName = deriveForumThreadName(renderedText);
|
|
503
504
|
const chunks = buildDiscordTextChunks(textWithMentions, {
|
|
504
505
|
maxLinesPerMessage,
|
|
@@ -528,6 +529,7 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
528
529
|
});
|
|
529
530
|
let threadRes;
|
|
530
531
|
try {
|
|
532
|
+
await opts.onPlatformSendDispatch?.();
|
|
531
533
|
threadRes = await request(() => createThread(rest, channelId, { body: {
|
|
532
534
|
name: threadName,
|
|
533
535
|
...channel.default_auto_archive_duration === void 0 ? {} : { auto_archive_duration: channel.default_auto_archive_duration },
|
|
@@ -546,18 +548,22 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
546
548
|
const messageId = threadRes.message?.id ?? threadId;
|
|
547
549
|
const resultChannelId = threadRes.message?.channel_id ?? threadId;
|
|
548
550
|
const remainingChunks = chunks.slice(1);
|
|
549
|
-
|
|
551
|
+
const starterResult = toDiscordSendResult({
|
|
550
552
|
id: messageId,
|
|
551
553
|
channel_id: resultChannelId
|
|
552
554
|
}, channelId, {
|
|
553
555
|
kind: "text",
|
|
554
556
|
threadId
|
|
555
|
-
})
|
|
557
|
+
});
|
|
558
|
+
const deliveredResults = [starterResult];
|
|
559
|
+
await opts.onDeliveryResult?.(starterResult);
|
|
556
560
|
const reportThreadResult = async (result, kind) => {
|
|
557
|
-
|
|
561
|
+
const deliveredResult = toDiscordSendResult(result, threadId, {
|
|
558
562
|
kind,
|
|
559
563
|
threadId
|
|
560
|
-
})
|
|
564
|
+
});
|
|
565
|
+
deliveredResults.push(deliveredResult);
|
|
566
|
+
await opts.onDeliveryResult?.(deliveredResult);
|
|
561
567
|
};
|
|
562
568
|
try {
|
|
563
569
|
if (opts.mediaUrl) {
|
|
@@ -579,7 +585,8 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
579
585
|
suppressEmbeds,
|
|
580
586
|
allowedMentions: opts.allowedMentions,
|
|
581
587
|
maxChars: textLimit,
|
|
582
|
-
onResult: reportThreadResult
|
|
588
|
+
onResult: reportThreadResult,
|
|
589
|
+
onPlatformSendDispatch: opts.onPlatformSendDispatch
|
|
583
590
|
});
|
|
584
591
|
await sendDiscordThreadTextChunks({
|
|
585
592
|
rest,
|
|
@@ -592,7 +599,8 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
592
599
|
silent: opts.silent,
|
|
593
600
|
suppressEmbeds,
|
|
594
601
|
allowedMentions: opts.allowedMentions,
|
|
595
|
-
onResult: reportThreadResult
|
|
602
|
+
onResult: reportThreadResult,
|
|
603
|
+
onPlatformSendDispatch: opts.onPlatformSendDispatch
|
|
596
604
|
});
|
|
597
605
|
} else await sendDiscordThreadTextChunks({
|
|
598
606
|
rest,
|
|
@@ -605,7 +613,8 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
605
613
|
silent: opts.silent,
|
|
606
614
|
suppressEmbeds,
|
|
607
615
|
allowedMentions: opts.allowedMentions,
|
|
608
|
-
onResult: reportThreadResult
|
|
616
|
+
onResult: reportThreadResult,
|
|
617
|
+
onPlatformSendDispatch: opts.onPlatformSendDispatch
|
|
609
618
|
});
|
|
610
619
|
} catch (err) {
|
|
611
620
|
throw await buildDiscordSendError(err, {
|
|
@@ -621,13 +630,13 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
621
630
|
accountId: accountInfo.accountId,
|
|
622
631
|
direction: "outbound"
|
|
623
632
|
});
|
|
624
|
-
return
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
633
|
+
return {
|
|
634
|
+
...starterResult,
|
|
635
|
+
receipt: createDiscordSendReceiptFromResults({
|
|
636
|
+
results: deliveredResults,
|
|
637
|
+
threadId
|
|
638
|
+
})
|
|
639
|
+
};
|
|
631
640
|
}
|
|
632
641
|
let result;
|
|
633
642
|
const reportResult = async (progressResult, kind, replyToId) => {
|
|
@@ -657,7 +666,8 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
657
666
|
suppressEmbeds,
|
|
658
667
|
allowedMentions: opts.allowedMentions,
|
|
659
668
|
maxChars: textLimit,
|
|
660
|
-
onResult: reportResult
|
|
669
|
+
onResult: reportResult,
|
|
670
|
+
onPlatformSendDispatch: opts.onPlatformSendDispatch
|
|
661
671
|
});
|
|
662
672
|
else result = await sendDiscordText({
|
|
663
673
|
rest,
|
|
@@ -673,7 +683,8 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
673
683
|
suppressEmbeds,
|
|
674
684
|
allowedMentions: opts.allowedMentions,
|
|
675
685
|
maxChars: textLimit,
|
|
676
|
-
onResult: reportResult
|
|
686
|
+
onResult: reportResult,
|
|
687
|
+
onPlatformSendDispatch: opts.onPlatformSendDispatch
|
|
677
688
|
});
|
|
678
689
|
} catch (err) {
|
|
679
690
|
throw await buildDiscordSendError(err, {
|
|
@@ -695,7 +706,8 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
695
706
|
});
|
|
696
707
|
}
|
|
697
708
|
async function sendStickerDiscord(to, stickerIds, opts) {
|
|
698
|
-
const
|
|
709
|
+
const context = await resolveDiscordStructuredSendContext(to, opts);
|
|
710
|
+
const { rewrittenContent, suppressEmbeds } = context;
|
|
699
711
|
const stickers = normalizeStickerIds(stickerIds);
|
|
700
712
|
const flags = resolveDiscordMessageFlags({ suppressEmbeds });
|
|
701
713
|
const body = {
|
|
@@ -705,10 +717,11 @@ async function sendStickerDiscord(to, stickerIds, opts) {
|
|
|
705
717
|
enforce_nonce: true,
|
|
706
718
|
...flags ? { flags } : {}
|
|
707
719
|
};
|
|
708
|
-
return
|
|
720
|
+
return context.send("sticker", body);
|
|
709
721
|
}
|
|
710
722
|
async function sendPollDiscord(to, poll, opts) {
|
|
711
|
-
const
|
|
723
|
+
const context = await resolveDiscordStructuredSendContext(to, opts);
|
|
724
|
+
const { rewrittenContent, suppressEmbeds } = context;
|
|
712
725
|
if (poll.durationSeconds !== void 0) throw new Error("Discord polls do not support durationSeconds; use durationHours");
|
|
713
726
|
const payload = normalizeDiscordPollInput(poll);
|
|
714
727
|
const flags = resolveDiscordMessageFlags({
|
|
@@ -722,7 +735,7 @@ async function sendPollDiscord(to, poll, opts) {
|
|
|
722
735
|
enforce_nonce: true,
|
|
723
736
|
...flags ? { flags } : {}
|
|
724
737
|
};
|
|
725
|
-
return
|
|
738
|
+
return context.send("poll", body);
|
|
726
739
|
}
|
|
727
740
|
async function resolveDiscordStructuredSendContext(to, opts) {
|
|
728
741
|
const accountInfo = resolveDiscordAccount({
|
|
@@ -732,9 +745,19 @@ async function resolveDiscordStructuredSendContext(to, opts) {
|
|
|
732
745
|
const { rest, request, channelId } = await resolveDiscordSendTarget(to, opts);
|
|
733
746
|
const content = opts.content?.trim();
|
|
734
747
|
return {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
748
|
+
send: async (kind, body) => {
|
|
749
|
+
await opts.onPlatformSendDispatch?.();
|
|
750
|
+
const result = await request(() => createChannelMessage(rest, channelId, { body }), kind, { safety: "nonce-protected-create" });
|
|
751
|
+
recordChannelActivity({
|
|
752
|
+
channel: "discord",
|
|
753
|
+
accountId: accountInfo.accountId,
|
|
754
|
+
direction: "outbound"
|
|
755
|
+
});
|
|
756
|
+
return toDiscordSendResult(result, channelId, {
|
|
757
|
+
kind: kind === "poll" ? "poll" : "card",
|
|
758
|
+
threadId: kind === "poll" ? opts.threadId : void 0
|
|
759
|
+
});
|
|
760
|
+
},
|
|
738
761
|
rewrittenContent: content ? rewriteDiscordKnownMentions(content, {
|
|
739
762
|
accountId: accountInfo.accountId,
|
|
740
763
|
mentionAliases: accountInfo.config.mentionAliases
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { P as createDiscordClient,
|
|
1
|
+
import { Tt as getChannelMessage, _t as listMessageReactionUsers, gt as deleteOwnMessageReaction, ht as createOwnMessageReaction } from "./retry-DNsVTeTo.js";
|
|
2
|
+
import { P as createDiscordClient, i as formatReactionEmoji, r as buildReactionIdentifier, s as normalizeReactionEmoji } from "./send.shared-B3fpaLWJ.js";
|
|
3
3
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
4
|
-
//#region extensions/discord/src/send.typing.ts
|
|
5
|
-
async function sendTypingDiscord(channelId, opts) {
|
|
6
|
-
await sendChannelTyping(resolveDiscordRest(opts), channelId);
|
|
7
|
-
return {
|
|
8
|
-
ok: true,
|
|
9
|
-
channelId
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
4
|
//#region extensions/discord/src/send.reactions.ts
|
|
14
5
|
function createDiscordReactionRuntimeClient(opts) {
|
|
15
6
|
return createDiscordClient(opts);
|
|
@@ -32,16 +23,17 @@ async function reactMessageDiscord(channelId, messageId, emoji, opts) {
|
|
|
32
23
|
return { ok: true };
|
|
33
24
|
}
|
|
34
25
|
async function removeReactionDiscord(channelId, messageId, emoji, opts) {
|
|
35
|
-
const { rest } = isDiscordReactionRuntimeContext(opts) ? createDiscordReactionRuntimeClient(opts) : resolveDiscordReactionClient(opts);
|
|
36
|
-
|
|
26
|
+
const { rest, request } = isDiscordReactionRuntimeContext(opts) ? createDiscordReactionRuntimeClient(opts) : resolveDiscordReactionClient(opts);
|
|
27
|
+
const encoded = normalizeReactionEmoji(emoji);
|
|
28
|
+
await request(() => deleteOwnMessageReaction(rest, channelId, messageId, encoded), "reaction-remove");
|
|
37
29
|
return { ok: true };
|
|
38
30
|
}
|
|
39
31
|
async function removeOwnReactionsDiscord(channelId, messageId, opts) {
|
|
40
|
-
const { rest } = isDiscordReactionRuntimeContext(opts) ? createDiscordReactionRuntimeClient(opts) : resolveDiscordReactionClient(opts);
|
|
41
|
-
const message = await getChannelMessage(rest, channelId, messageId);
|
|
32
|
+
const { rest, request } = isDiscordReactionRuntimeContext(opts) ? createDiscordReactionRuntimeClient(opts) : resolveDiscordReactionClient(opts);
|
|
33
|
+
const message = await request(() => getChannelMessage(rest, channelId, messageId), "reaction-list");
|
|
42
34
|
const identifiers = /* @__PURE__ */ new Set();
|
|
43
35
|
for (const reaction of message.reactions ?? []) {
|
|
44
|
-
const identifier = buildReactionIdentifier(reaction.emoji);
|
|
36
|
+
const identifier = reaction.me ? buildReactionIdentifier(reaction.emoji) : void 0;
|
|
45
37
|
if (identifier) identifiers.add(identifier);
|
|
46
38
|
}
|
|
47
39
|
if (identifiers.size === 0) return {
|
|
@@ -49,22 +41,23 @@ async function removeOwnReactionsDiscord(channelId, messageId, opts) {
|
|
|
49
41
|
removed: []
|
|
50
42
|
};
|
|
51
43
|
const removed = Array.from(identifiers);
|
|
52
|
-
await Promise.all(removed.map((identifier) => deleteOwnMessageReaction(rest, channelId, messageId, normalizeReactionEmoji(identifier))));
|
|
44
|
+
await Promise.all(removed.map((identifier) => request(() => deleteOwnMessageReaction(rest, channelId, messageId, normalizeReactionEmoji(identifier)), "reaction-remove")));
|
|
53
45
|
return {
|
|
54
46
|
ok: true,
|
|
55
47
|
removed
|
|
56
48
|
};
|
|
57
49
|
}
|
|
58
50
|
async function fetchReactionsDiscord(channelId, messageId, opts) {
|
|
59
|
-
const { rest } = isDiscordReactionRuntimeContext(opts) ? createDiscordReactionRuntimeClient(opts) : resolveDiscordReactionClient(opts);
|
|
60
|
-
const reactions = (await getChannelMessage(rest, channelId, messageId)).reactions ?? [];
|
|
51
|
+
const { rest, request } = isDiscordReactionRuntimeContext(opts) ? createDiscordReactionRuntimeClient(opts) : resolveDiscordReactionClient(opts);
|
|
52
|
+
const reactions = (await request(() => getChannelMessage(rest, channelId, messageId), "reaction-list")).reactions ?? [];
|
|
61
53
|
if (reactions.length === 0) return [];
|
|
62
54
|
const limit = typeof opts.limit === "number" && Number.isFinite(opts.limit) ? Math.min(Math.max(Math.floor(opts.limit), 1), 100) : 100;
|
|
63
55
|
const summaries = [];
|
|
64
56
|
for (const reaction of reactions) {
|
|
65
57
|
const identifier = buildReactionIdentifier(reaction.emoji);
|
|
66
58
|
if (!identifier) continue;
|
|
67
|
-
const
|
|
59
|
+
const encoded = encodeURIComponent(identifier);
|
|
60
|
+
const users = await request(() => listMessageReactionUsers(rest, channelId, messageId, encoded, { limit }), "reaction-users");
|
|
68
61
|
summaries.push({
|
|
69
62
|
emoji: {
|
|
70
63
|
id: reaction.emoji.id ?? null,
|
|
@@ -82,4 +75,4 @@ async function fetchReactionsDiscord(channelId, messageId, opts) {
|
|
|
82
75
|
return summaries;
|
|
83
76
|
}
|
|
84
77
|
//#endregion
|
|
85
|
-
export {
|
|
78
|
+
export { removeReactionDiscord as i, reactMessageDiscord as n, removeOwnReactionsDiscord as r, fetchReactionsDiscord as t };
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
|
|
2
|
+
import { attachChannelToResults } from "openclaw/plugin-sdk/channel-send-result";
|
|
2
3
|
//#region extensions/discord/src/send.receipt.ts
|
|
4
|
+
function toDiscordOutboundDeliveryResult(result) {
|
|
5
|
+
const { channelId, ...delivery } = result;
|
|
6
|
+
return {
|
|
7
|
+
...delivery,
|
|
8
|
+
target: {
|
|
9
|
+
kind: "channel",
|
|
10
|
+
id: channelId
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function createDiscordSendReceiptFromResults(params) {
|
|
15
|
+
const receipt = createMessageReceiptFromOutboundResults({
|
|
16
|
+
results: attachChannelToResults("discord", params.results),
|
|
17
|
+
threadId: params.threadId
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
...receipt,
|
|
21
|
+
parts: receipt.parts.map(({ platformMessageId, kind, threadId, replyToId, raw }, index) => ({
|
|
22
|
+
platformMessageId,
|
|
23
|
+
kind,
|
|
24
|
+
index,
|
|
25
|
+
threadId,
|
|
26
|
+
replyToId,
|
|
27
|
+
raw
|
|
28
|
+
}))
|
|
29
|
+
};
|
|
30
|
+
}
|
|
3
31
|
function createDiscordSendReceipt(params) {
|
|
4
32
|
return createMessageReceiptFromOutboundResults({
|
|
5
33
|
results: params.platformMessageIds.map((messageId) => messageId.trim()).filter((messageId) => messageId && messageId !== "unknown").map((messageId, index) => {
|
|
@@ -45,4 +73,4 @@ function createDiscordSendResult(params) {
|
|
|
45
73
|
};
|
|
46
74
|
}
|
|
47
75
|
//#endregion
|
|
48
|
-
export {
|
|
76
|
+
export { toDiscordOutboundDeliveryResult as i, createDiscordSendReceiptFromResults as n, createDiscordSendResult as r, createDiscordSendReceipt as t };
|