@openclaw/discord 2026.5.7 → 2026.5.10-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{access-CHY9FK3X.js → access-R4X7pYt4.js} +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/{allow-list-ek-1hMKN.js → allow-list-4wnZg5P9.js} +2 -6
- package/dist/api.js +18 -16
- package/dist/{approval-handler.runtime-BBZRYAGs.js → approval-handler.runtime-B5BCBw4D.js} +3 -4
- package/dist/{approval-native-CBdZsAR7.js → approval-native-CrCc3b4u.js} +2 -2
- package/dist/{approval-shared-Ck6TxKgo.js → approval-shared-Ckk65xSG.js} +1 -1
- package/dist/{audit-CCJ0h49k.js → audit-BRBe8xFv.js} +4 -4
- package/dist/{channel-UXGa9PGc.js → channel-DTBEGHsT.js} +53 -31
- package/dist/{channel-actions-Br29_1nE.js → channel-actions-CHgoSpPF.js} +27 -1
- package/dist/{channel-actions.runtime-ChmNUig1.js → channel-actions.runtime-E5Plubuu.js} +5 -5
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-D_xyQu_h.js → channel.setup-EQXuueIk.js} +3 -3
- package/dist/chunk-DYl-_5RL.js +179 -0
- package/dist/{components-D5LnN7ZQ.js → components-BJOShoIU.js} +2 -3
- package/dist/{config-schema-Cc953rAs.js → config-schema-BGn5I3_3.js} +46 -1
- package/dist/contract-api.js +7 -7
- package/dist/{conversation-identity-DHhS0ez3.js → conversation-identity-BPQm_uhV.js} +1 -1
- package/dist/{directory-config-DoETeOOx.js → directory-config-JBaFwbAQ.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-DJ0V5asB.js → directory-live-B4kW11z5.js} +2 -2
- package/dist/{discord-eZlimVfW.js → discord-DtHMmZqJ.js} +58 -15
- package/dist/{doctor-Bo-yifB3.js → doctor-CPV4Ch3V.js} +3 -3
- package/dist/{doctor-contract-Bso46EOQ.js → doctor-contract-BGjjFBdq.js} +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{handle-action.guild-admin-sJiQymg8.js → handle-action.guild-admin-DSeMCHvR.js} +6 -3
- package/dist/{inbound-context-CRylwjg0.js → inbound-context-BAwOn5Iq.js} +1 -1
- package/dist/manager.runtime-DGvCDWI5.js +2082 -0
- package/dist/{message-handler-C9Ohf-ea.js → message-handler-BWHSteQf.js} +7 -7
- package/dist/{message-handler.preflight-BrvazsYn.js → message-handler.preflight-q7ose9Ta.js} +31 -42
- package/dist/{message-handler.process-CEnzuLiN.js → message-handler.process-BN8bE7AE.js} +81 -64
- package/dist/{message-utils-9kaGF59d.js → message-utils-DEjCwCRz.js} +2 -2
- package/dist/normalize-Cu94FOqy.js +58 -0
- package/dist/{outbound-adapter-DNsTVJfH.js → outbound-adapter-Bt8FL3yO.js} +78 -17
- package/dist/{outbound-session-route-DK9qkPgP.js → outbound-session-route-BaJRt05p.js} +1 -1
- package/dist/{pluralkit-OFss_pIy.js → pluralkit-CUfobeQu.js} +1 -1
- package/dist/{preflight-audio-CRmUxxuM.js → preflight-audio-BcsH127L.js} +1 -1
- package/dist/{preview-streaming-Cc_oeIPP.js → preview-streaming-DCPAe24T.js} +1 -0
- package/dist/{probe.runtime-CMgUDax3.js → probe.runtime-4Q9GD7FG.js} +1 -1
- package/dist/{provider-CuOh6z_b.js → provider-DBvvDP9A.js} +185 -225
- package/dist/{provider-session.runtime-CCESIHVo.js → provider-session.runtime-DepAOR1U.js} +3 -3
- package/dist/provider.runtime-BlbOt97W.js +2 -0
- package/dist/{reply-delivery-D9aKHtDH.js → reply-delivery-vHSqaKKo.js} +9 -6
- package/dist/{resolve-allowlist-common-_e1cWOb3.js → resolve-allowlist-common-ZcVU4OMA.js} +1 -1
- package/dist/{resolve-channels-kyuvrXJg.js → resolve-channels-D9Dubj_y.js} +3 -3
- package/dist/{resolve-users-CAwh4EBq.js → resolve-users-DlzKsLQe.js} +2 -2
- package/dist/route-resolution-foWW8_D1.js +268 -0
- package/dist/runtime-api.actions.js +2 -2
- package/dist/runtime-api.js +25 -25
- package/dist/runtime-api.lookup.js +6 -6
- package/dist/runtime-api.monitor-CsetE9pd.js +6 -0
- package/dist/runtime-api.monitor.js +7 -7
- package/dist/runtime-api.send.js +5 -5
- package/dist/runtime-api.threads.js +5 -5
- package/dist/{runtime-D8alY00g.js → runtime-oXRGbcb5.js} +7 -7
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/{security-audit-BtRd_VhN.js → security-audit-BQ_sGK3J.js} +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/{security-audit.runtime-Dm1LW9KX.js → security-audit.runtime-B7Gmz2DX.js} +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/{send-8S_HKJpQ.js → send-BSBMchf8.js} +83 -57
- package/dist/{send.components-A42c_5tQ.js → send.components-BoEhxys4.js} +22 -15
- package/dist/{send.outbound-D3tonSz8.js → send.outbound-B2DK2loZ.js} +22 -11
- package/dist/send.receipt-BAZw2Zsz.js +35 -0
- package/dist/{send.shared-BQGiUPvZ.js → send.shared-DzwpAEMP.js} +26 -7
- package/dist/session-key-api.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-BEW4H3bj.js → shared-CBsrEG5q.js} +8 -8
- package/dist/{shared-interactive-KgJjCqnB.js → shared-interactive-D39V9Wtn.js} +3 -3
- package/dist/{subagent-hooks-T0LPLh4H.js → subagent-hooks-BDy1pJD5.js} +2 -2
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/{system-events-_fzSG--3.js → system-events-BeVImqnV.js} +1 -1
- package/dist/target-parsing-D-H7nnh2.js +51 -0
- package/dist/target-resolver-DzOelJEt.js +85 -0
- package/dist/targets-Dj-qyUaE.js +3 -0
- package/dist/test-api.js +4 -4
- package/dist/{thread-bindings-CMpZjP50.js → thread-bindings-DUzBL8jL.js} +7 -7
- package/dist/{thread-bindings.discord-api-CwWGoyei.js → thread-bindings.discord-api-dpSDYFKX.js} +7 -7
- package/dist/{thread-bindings.manager-BtxfLfWf.js → thread-bindings.manager-DTuwm8Tk.js} +5 -6
- package/dist/{thread-bindings.session-updates-jcZSiRPI.js → thread-bindings.session-updates-BhcGQTJb.js} +1 -1
- package/dist/{threading-BMmpA2JR.js → threading-CTUnZtNi.js} +4 -5
- package/dist/timeouts.js +1 -1
- package/dist/{typing-Bw6NKWLZ.js → typing-BYeVSviE.js} +2 -3
- package/openclaw.plugin.json +222 -1
- package/package.json +5 -5
- package/dist/manager.runtime-Cug1PoeZ.js +0 -1025
- package/dist/provider.runtime-B68g3qLv.js +0 -2
- package/dist/rolldown-runtime-C3SqQTfK.js +0 -28
- package/dist/route-resolution-BWErj5Cn.js +0 -236
- package/dist/runtime-api.monitor-DzkCxeBL.js +0 -6
- package/dist/target-resolver-DA84_xbt.js +0 -365
- package/dist/targets-FwL1BPTU.js +0 -2
- /package/dist/{agent-components.runtime-Dof1YMSz.js → agent-components.runtime-zT8qPsnM.js} +0 -0
- /package/dist/{audit-core-CejGc3hO.js → audit-core-CG37TsZm.js} +0 -0
- /package/dist/{channel-access-DFIQqbYm.js → channel-access-BL-wemES.js} +0 -0
- /package/dist/{doctor-shared-Cqvfgv9m.js → doctor-shared-D_QLzu30.js} +0 -0
- /package/dist/{mentions-BPZUaFk7.js → mentions-f806C7MB.js} +0 -0
- /package/dist/{preflight-audio.runtime-DPVbpZid.js → preflight-audio.runtime-fXnUxxBa.js} +0 -0
- /package/dist/{probe-E80IMT1X.js → probe-CjO53qsc.js} +0 -0
- /package/dist/{runtime-K9RT6Egn.js → runtime-BqCoo-zp.js} +0 -0
- /package/dist/{secret-config-contract-5S9U9pjx.js → secret-config-contract-BCQNNS7N.js} +0 -0
- /package/dist/{security-contract-BE8rsdPq.js → security-contract-DrbQqyyW.js} +0 -0
- /package/dist/{security-doctor-DiilN216.js → security-doctor-BJH5YIGL.js} +0 -0
- /package/dist/{sender-identity-BGUfyvOC.js → sender-identity-CDOVm5Dk.js} +0 -0
- /package/dist/{session-contract-CuW9Nlxg.js → session-contract-D871HDFG.js} +0 -0
- /package/dist/{session-key-normalization-B5La-jFM.js → session-key-normalization-BQNCS1gu.js} +0 -0
- /package/dist/{thread-bindings.state-WU4duXKY.js → thread-bindings.state-DwgDYzBM.js} +0 -0
- /package/dist/{timeouts-CdsmBWWs.js → timeouts-C3FYXWJX.js} +0 -0
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as createChannelMessage, At as putChannelPermission, Ct as getGuildVoiceState, Dt as listGuildRoles, Et as listGuildEmojis, Mt as removeGuildMemberRole, Nt as timeoutGuildMember, Ot as listGuildScheduledEvents, Pt as __exportAll, Q as listMessageReactionUsers, St as getGuildMember, Tt as listGuildChannels, X as createOwnMessageReaction, Z as deleteOwnMessageReaction, _ as readDiscordMessage, _t as createGuildEmoji, at as getChannel, bt as deleteChannelPermission, ct as listChannelMessages, dt as searchGuildMessages, et as createThread, ft as sendChannelTyping, g as readDiscordCode, gt as createGuildChannel, h as RateLimitError, ht as createGuildBan, it as editChannelMessage, jt as removeGuildMember, kt as moveGuildChannels, lt as listChannelPins, m as DiscordError, mt as addGuildMemberRole, nt as deleteChannelMessage, ot as getChannelMessage, pt as unpinChannelMessage, rt as editChannel, st as listChannelArchivedThreads, tt as deleteChannel, ut as pinChannelMessage, v as readRetryAfter, vt as createGuildScheduledEvent, wt as listGuildActiveThreads, yt as createGuildSticker } from "./discord-DtHMmZqJ.js";
|
|
2
2
|
import { s as resolveDiscordAccount } from "./accounts-CaHGiVB4.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
6
|
-
import { n as sendPollDiscord, r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-
|
|
3
|
+
import { A as createDiscordClient, C as DiscordSendError, D as hasAllGuildPermissionsDiscord, E as fetchMemberGuildPermissionsDiscord, N as resolveDiscordClientAccountContext, O as hasAnyGuildPermissionDiscord, P as resolveDiscordRest, S as DISCORD_MAX_STICKER_BYTES, T as fetchChannelPermissionsDiscord, b as DISCORD_MAX_EMOJI_BYTES, i as formatReactionEmoji, k as parseAndResolveRecipient, l as resolveChannelId, o as normalizeEmojiName, r as buildReactionIdentifier, s as normalizeReactionEmoji, t as buildDiscordSendError, w as canViewDiscordGuildChannel, x as DISCORD_MAX_EVENT_COVER_BYTES } from "./send.shared-DzwpAEMP.js";
|
|
4
|
+
import { n as rewriteDiscordKnownMentions } from "./mentions-f806C7MB.js";
|
|
5
|
+
import { n as createDiscordSendResult } from "./send.receipt-BAZw2Zsz.js";
|
|
6
|
+
import { n as sendPollDiscord, r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-B2DK2loZ.js";
|
|
7
7
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
|
8
8
|
import { ChannelType } from "discord-api-types/v10";
|
|
9
9
|
import crypto from "node:crypto";
|
|
10
|
-
import fs from "node:fs/promises";
|
|
11
10
|
import path from "node:path";
|
|
11
|
+
import { writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime";
|
|
12
12
|
import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, extensionForMime, maxBytesForKind, parseFfprobeCodecAndSampleRate, runFfmpeg, runFfprobe, unlinkIfExists } from "openclaw/plugin-sdk/media-runtime";
|
|
13
13
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
14
14
|
import { loadWebMediaRaw } from "openclaw/plugin-sdk/web-media";
|
|
15
15
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
16
16
|
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
17
|
-
import
|
|
17
|
+
import fs from "node:fs/promises";
|
|
18
|
+
import { resolvePreferredOpenClawTmpDir, tempWorkspace } from "openclaw/plugin-sdk/temp-path";
|
|
18
19
|
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
19
20
|
//#region extensions/discord/src/send.channels.ts
|
|
20
21
|
async function createChannelDiscord(payload, opts) {
|
|
@@ -352,10 +353,13 @@ async function sendWebhookMessageDiscord(text, opts) {
|
|
|
352
353
|
direction: "outbound"
|
|
353
354
|
});
|
|
354
355
|
} catch {}
|
|
355
|
-
return {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
return createDiscordSendResult({
|
|
357
|
+
result: payload,
|
|
358
|
+
fallbackChannelId: opts.threadId ? String(opts.threadId) : "",
|
|
359
|
+
kind: "text",
|
|
360
|
+
...opts.threadId != null ? { threadId: opts.threadId } : {},
|
|
361
|
+
...replyTo ? { replyToId: replyTo } : {}
|
|
362
|
+
});
|
|
359
363
|
}
|
|
360
364
|
//#endregion
|
|
361
365
|
//#region extensions/discord/src/voice-message.ts
|
|
@@ -374,6 +378,17 @@ const DISCORD_VOICE_MESSAGE_FLAG = 8192;
|
|
|
374
378
|
const SUPPRESS_NOTIFICATIONS_FLAG = 4096;
|
|
375
379
|
const WAVEFORM_SAMPLES = 256;
|
|
376
380
|
const DISCORD_OPUS_SAMPLE_RATE_HZ = 48e3;
|
|
381
|
+
async function runFfmpegToOutput(params) {
|
|
382
|
+
const rootDir = path.dirname(params.outputPath);
|
|
383
|
+
await fs.mkdir(rootDir, { recursive: true });
|
|
384
|
+
await writeExternalFileWithinRoot({
|
|
385
|
+
rootDir,
|
|
386
|
+
path: path.basename(params.outputPath),
|
|
387
|
+
write: async (tempPath) => {
|
|
388
|
+
await runFfmpeg(params.buildArgs(tempPath));
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
377
392
|
function createRateLimitError(response, body, request) {
|
|
378
393
|
return new RateLimitError(response, body, request ?? new Request("https://discord.com/api/v10/channels/voice/messages", { method: "POST" }));
|
|
379
394
|
}
|
|
@@ -417,25 +432,28 @@ async function generateWaveformFromPcm(filePath) {
|
|
|
417
432
|
const tempDir = resolvePreferredOpenClawTmpDir();
|
|
418
433
|
const tempPcm = path.join(tempDir, `waveform-${crypto.randomUUID()}.raw`);
|
|
419
434
|
try {
|
|
420
|
-
await
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
435
|
+
await runFfmpegToOutput({
|
|
436
|
+
outputPath: tempPcm,
|
|
437
|
+
buildArgs: (outputPath) => [
|
|
438
|
+
"-y",
|
|
439
|
+
"-i",
|
|
440
|
+
filePath,
|
|
441
|
+
"-vn",
|
|
442
|
+
"-sn",
|
|
443
|
+
"-dn",
|
|
444
|
+
"-t",
|
|
445
|
+
String(MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS),
|
|
446
|
+
"-f",
|
|
447
|
+
"s16le",
|
|
448
|
+
"-acodec",
|
|
449
|
+
"pcm_s16le",
|
|
450
|
+
"-ac",
|
|
451
|
+
"1",
|
|
452
|
+
"-ar",
|
|
453
|
+
"8000",
|
|
454
|
+
outputPath
|
|
455
|
+
]
|
|
456
|
+
});
|
|
439
457
|
const pcmData = await fs.readFile(tempPcm);
|
|
440
458
|
const samples = new Int16Array(pcmData.buffer, pcmData.byteOffset, pcmData.byteLength / 2);
|
|
441
459
|
const step = Math.max(1, Math.floor(samples.length / WAVEFORM_SAMPLES));
|
|
@@ -494,23 +512,26 @@ async function ensureOggOpus(filePath) {
|
|
|
494
512
|
} catch {}
|
|
495
513
|
const tempDir = resolvePreferredOpenClawTmpDir();
|
|
496
514
|
const outputPath = path.join(tempDir, `voice-${crypto.randomUUID()}.ogg`);
|
|
497
|
-
await
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
515
|
+
await runFfmpegToOutput({
|
|
516
|
+
outputPath,
|
|
517
|
+
buildArgs: (tempPath) => [
|
|
518
|
+
"-y",
|
|
519
|
+
"-i",
|
|
520
|
+
filePath,
|
|
521
|
+
"-vn",
|
|
522
|
+
"-sn",
|
|
523
|
+
"-dn",
|
|
524
|
+
"-t",
|
|
525
|
+
String(MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS),
|
|
526
|
+
"-ar",
|
|
527
|
+
String(DISCORD_OPUS_SAMPLE_RATE_HZ),
|
|
528
|
+
"-c:a",
|
|
529
|
+
"libopus",
|
|
530
|
+
"-b:a",
|
|
531
|
+
"64k",
|
|
532
|
+
tempPath
|
|
533
|
+
]
|
|
534
|
+
});
|
|
514
535
|
return {
|
|
515
536
|
path: outputPath,
|
|
516
537
|
cleanup: true
|
|
@@ -631,20 +652,25 @@ async function sendDiscordVoiceMessage(rest, channelId, audioBuffer, metadata, r
|
|
|
631
652
|
//#endregion
|
|
632
653
|
//#region extensions/discord/src/send.voice.ts
|
|
633
654
|
function toDiscordSendResult(result, fallbackChannelId) {
|
|
634
|
-
return {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
655
|
+
return createDiscordSendResult({
|
|
656
|
+
result,
|
|
657
|
+
fallbackChannelId,
|
|
658
|
+
kind: "voice"
|
|
659
|
+
});
|
|
638
660
|
}
|
|
639
661
|
async function materializeVoiceMessageInput(mediaUrl) {
|
|
640
662
|
const media = await loadWebMediaRaw(mediaUrl, maxBytesForKind("audio"));
|
|
641
663
|
const extFromName = media.fileName ? path.extname(media.fileName) : "";
|
|
642
664
|
const extFromMime = media.contentType ? extensionForMime(media.contentType) : "";
|
|
643
665
|
const ext = extFromName || extFromMime || ".bin";
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
666
|
+
const workspace = await tempWorkspace({
|
|
667
|
+
rootDir: resolvePreferredOpenClawTmpDir(),
|
|
668
|
+
prefix: "voice-src-"
|
|
669
|
+
});
|
|
670
|
+
return {
|
|
671
|
+
filePath: await workspace.write(`input${ext}`, media.buffer),
|
|
672
|
+
cleanup: async () => await workspace.cleanup()
|
|
673
|
+
};
|
|
648
674
|
}
|
|
649
675
|
/**
|
|
650
676
|
* Send a voice message to Discord.
|
|
@@ -657,7 +683,7 @@ async function materializeVoiceMessageInput(mediaUrl) {
|
|
|
657
683
|
* @param opts - Send options
|
|
658
684
|
*/
|
|
659
685
|
async function sendVoiceMessageDiscord(to, audioPath, opts) {
|
|
660
|
-
const { filePath: localInputPath } = await materializeVoiceMessageInput(audioPath);
|
|
686
|
+
const { filePath: localInputPath, cleanup: cleanupLocalInput } = await materializeVoiceMessageInput(audioPath);
|
|
661
687
|
let oggPath = null;
|
|
662
688
|
let oggCleanup = false;
|
|
663
689
|
let token;
|
|
@@ -701,7 +727,7 @@ async function sendVoiceMessageDiscord(to, audioPath, opts) {
|
|
|
701
727
|
throw err;
|
|
702
728
|
} finally {
|
|
703
729
|
await unlinkIfExists(oggCleanup ? oggPath : null);
|
|
704
|
-
await
|
|
730
|
+
await cleanupLocalInput();
|
|
705
731
|
}
|
|
706
732
|
}
|
|
707
733
|
//#endregion
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as createChannelMessage, Pt as __exportAll, it as editChannelMessage, w as serializePayload } from "./discord-DtHMmZqJ.js";
|
|
2
2
|
import { s as resolveDiscordAccount } from "./accounts-CaHGiVB4.js";
|
|
3
3
|
import "./config-api-CFZtoMaS.js";
|
|
4
4
|
import "./channel-api-CTSWMrnD.js";
|
|
5
|
-
import "./outbound-session-route-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { t as sendMessageDiscord } from "./send.outbound-
|
|
9
|
-
import { a as buildDiscordComponentMessage, l as resolveDiscordComponentAttachmentName, o as buildDiscordComponentMessageFlags } from "./components-
|
|
10
|
-
import { n as getOptionalDiscordRuntime } from "./runtime-
|
|
5
|
+
import "./outbound-session-route-BaJRt05p.js";
|
|
6
|
+
import { A as createDiscordClient, h as SUPPRESS_NOTIFICATIONS_FLAG, k as parseAndResolveRecipient, l as resolveChannelId, m as toDiscordFileBlob, t as buildDiscordSendError, u as resolveDiscordChannelType, y as stripUndefinedFields } from "./send.shared-DzwpAEMP.js";
|
|
7
|
+
import { n as createDiscordSendResult } from "./send.receipt-BAZw2Zsz.js";
|
|
8
|
+
import { t as sendMessageDiscord } from "./send.outbound-B2DK2loZ.js";
|
|
9
|
+
import { a as buildDiscordComponentMessage, l as resolveDiscordComponentAttachmentName, o as buildDiscordComponentMessageFlags } from "./components-BJOShoIU.js";
|
|
10
|
+
import { n as getOptionalDiscordRuntime } from "./runtime-BqCoo-zp.js";
|
|
11
11
|
import "openclaw/plugin-sdk/account-id";
|
|
12
12
|
import "openclaw/plugin-sdk/secret-input";
|
|
13
13
|
import "openclaw/plugin-sdk/account-helpers";
|
|
@@ -417,10 +417,12 @@ async function sendDiscordComponentMessage(to, spec, opts) {
|
|
|
417
417
|
accountId: accountInfo.accountId,
|
|
418
418
|
direction: "outbound"
|
|
419
419
|
});
|
|
420
|
-
return {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
420
|
+
return createDiscordSendResult({
|
|
421
|
+
result,
|
|
422
|
+
fallbackChannelId: channelId,
|
|
423
|
+
kind: "card",
|
|
424
|
+
...opts.replyTo ? { replyToId: opts.replyTo } : {}
|
|
425
|
+
});
|
|
424
426
|
}
|
|
425
427
|
async function editDiscordComponentMessage(to, messageId, spec, opts) {
|
|
426
428
|
const cfg = requireRuntimeConfig(opts.cfg, "Discord component edit");
|
|
@@ -459,10 +461,15 @@ async function editDiscordComponentMessage(to, messageId, spec, opts) {
|
|
|
459
461
|
accountId: accountInfo.accountId,
|
|
460
462
|
direction: "outbound"
|
|
461
463
|
});
|
|
462
|
-
return {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
return createDiscordSendResult({
|
|
465
|
+
result: {
|
|
466
|
+
id: result.id ?? messageId,
|
|
467
|
+
channel_id: result.channel_id
|
|
468
|
+
},
|
|
469
|
+
fallbackChannelId: channelId,
|
|
470
|
+
kind: "card",
|
|
471
|
+
...opts.replyTo ? { replyToId: opts.replyTo } : {}
|
|
472
|
+
});
|
|
466
473
|
}
|
|
467
474
|
//#endregion
|
|
468
475
|
export { resolveDiscordComponentEntryWithPersistence as a, jsonResult as c, readNumberParam as d, readReactionParams as f, withNormalizedTimestamp as g, resolvePollMaxSelections as h, send_components_exports as i, parseAvailableTags as l, readStringParam as m, registerBuiltDiscordComponentMessage as n, resolveDiscordModalEntryWithPersistence as o, readStringArrayParam as p, sendDiscordComponentMessage as r, assertMediaNotDataUrl as s, editDiscordComponentMessage as t, readBooleanParam$1 as u };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { $ as createChannelMessage, et as createThread } from "./discord-DtHMmZqJ.js";
|
|
1
2
|
import { s as resolveDiscordAccount } from "./accounts-CaHGiVB4.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
3
|
+
import { A as createDiscordClient, _ as resolveDiscordSendComponents, a as normalizeDiscordPollInput, c as normalizeStickerIds, f as sendDiscordMedia, g as buildDiscordMessageRequest, h as SUPPRESS_NOTIFICATIONS_FLAG, k as parseAndResolveRecipient, l as resolveChannelId, n as buildDiscordTextChunks, p as sendDiscordText, t as buildDiscordSendError, u as resolveDiscordChannelType, v as resolveDiscordSendEmbeds } from "./send.shared-DzwpAEMP.js";
|
|
4
|
+
import { n as rewriteDiscordKnownMentions } from "./mentions-f806C7MB.js";
|
|
5
|
+
import { n as createDiscordSendResult } from "./send.receipt-BAZw2Zsz.js";
|
|
5
6
|
import { convertMarkdownTables, normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
|
6
7
|
import { ChannelType } from "discord-api-types/v10";
|
|
7
8
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
@@ -23,11 +24,15 @@ function deriveForumThreadName(text) {
|
|
|
23
24
|
function isForumLikeType(channelType) {
|
|
24
25
|
return channelType === ChannelType.GuildForum || channelType === ChannelType.GuildMedia;
|
|
25
26
|
}
|
|
26
|
-
function toDiscordSendResult(result, fallbackChannelId) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
function toDiscordSendResult(result, fallbackChannelId, params = {}) {
|
|
28
|
+
const resultParams = {
|
|
29
|
+
result,
|
|
30
|
+
fallbackChannelId,
|
|
31
|
+
kind: params.kind ?? "text"
|
|
30
32
|
};
|
|
33
|
+
if (params.threadId != null) resultParams.threadId = params.threadId;
|
|
34
|
+
if (params.replyToId) resultParams.replyToId = params.replyToId;
|
|
35
|
+
return createDiscordSendResult(resultParams);
|
|
31
36
|
}
|
|
32
37
|
async function resolveDiscordSendTarget(to, opts) {
|
|
33
38
|
const cfg = requireRuntimeConfig(opts.cfg, "Discord send target resolution");
|
|
@@ -149,7 +154,10 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
149
154
|
return toDiscordSendResult({
|
|
150
155
|
id: messageId,
|
|
151
156
|
channel_id: resultChannelId
|
|
152
|
-
}, channelId
|
|
157
|
+
}, channelId, {
|
|
158
|
+
kind: opts.mediaUrl ? "media" : "text",
|
|
159
|
+
threadId
|
|
160
|
+
});
|
|
153
161
|
}
|
|
154
162
|
let result;
|
|
155
163
|
try {
|
|
@@ -169,7 +177,10 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
169
177
|
accountId: accountInfo.accountId,
|
|
170
178
|
direction: "outbound"
|
|
171
179
|
});
|
|
172
|
-
return toDiscordSendResult(result, channelId
|
|
180
|
+
return toDiscordSendResult(result, channelId, {
|
|
181
|
+
kind: opts.mediaUrl ? "media" : opts.components || opts.embeds ? "card" : "text",
|
|
182
|
+
replyToId: opts.replyTo
|
|
183
|
+
});
|
|
173
184
|
}
|
|
174
185
|
async function sendStickerDiscord(to, stickerIds, opts) {
|
|
175
186
|
const { rest, request, channelId, rewrittenContent } = await resolveDiscordStructuredSendContext(to, opts);
|
|
@@ -177,7 +188,7 @@ async function sendStickerDiscord(to, stickerIds, opts) {
|
|
|
177
188
|
return toDiscordSendResult(await request(() => createChannelMessage(rest, channelId, { body: {
|
|
178
189
|
content: rewrittenContent || void 0,
|
|
179
190
|
sticker_ids: stickers
|
|
180
|
-
} }), "sticker"), channelId);
|
|
191
|
+
} }), "sticker"), channelId, { kind: "card" });
|
|
181
192
|
}
|
|
182
193
|
async function sendPollDiscord(to, poll, opts) {
|
|
183
194
|
const { rest, request, channelId, rewrittenContent } = await resolveDiscordStructuredSendContext(to, opts);
|
|
@@ -188,7 +199,7 @@ async function sendPollDiscord(to, poll, opts) {
|
|
|
188
199
|
content: rewrittenContent || void 0,
|
|
189
200
|
poll: payload,
|
|
190
201
|
...flags ? { flags } : {}
|
|
191
|
-
} }), "poll"), channelId);
|
|
202
|
+
} }), "poll"), channelId, { kind: "card" });
|
|
192
203
|
}
|
|
193
204
|
async function resolveDiscordStructuredSendContext(to, opts) {
|
|
194
205
|
const accountInfo = resolveDiscordAccount({
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-message";
|
|
2
|
+
//#region extensions/discord/src/send.receipt.ts
|
|
3
|
+
function createDiscordSendReceipt(params) {
|
|
4
|
+
return createMessageReceiptFromOutboundResults({
|
|
5
|
+
results: params.platformMessageIds.map((messageId) => messageId.trim()).filter((messageId) => messageId && messageId !== "unknown").map((messageId) => {
|
|
6
|
+
const result = {
|
|
7
|
+
channel: "discord",
|
|
8
|
+
messageId
|
|
9
|
+
};
|
|
10
|
+
if (params.channelId) result.channelId = params.channelId;
|
|
11
|
+
return result;
|
|
12
|
+
}),
|
|
13
|
+
kind: params.kind,
|
|
14
|
+
threadId: params.threadId,
|
|
15
|
+
replyToId: params.replyToId
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function createDiscordSendResult(params) {
|
|
19
|
+
const messageId = params.result.id || "unknown";
|
|
20
|
+
const channelId = params.result.channel_id ?? params.fallbackChannelId;
|
|
21
|
+
const receiptParams = {
|
|
22
|
+
platformMessageIds: params.result.platformMessageIds?.length ? params.result.platformMessageIds : [messageId],
|
|
23
|
+
channelId,
|
|
24
|
+
kind: params.kind
|
|
25
|
+
};
|
|
26
|
+
if (params.threadId != null) receiptParams.threadId = String(params.threadId);
|
|
27
|
+
if (params.replyToId) receiptParams.replyToId = params.replyToId;
|
|
28
|
+
return {
|
|
29
|
+
messageId,
|
|
30
|
+
channelId,
|
|
31
|
+
receipt: createDiscordSendReceipt(receiptParams)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { createDiscordSendResult as n, createDiscordSendReceipt as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { $ as createChannelMessage, J as createUserDmChannel, St as getGuildMember, Y as getCurrentUser, at as getChannel, h as RateLimitError, p as RequestClient, u as Embed, w as serializePayload, xt as getGuild } from "./discord-DtHMmZqJ.js";
|
|
1
2
|
import { t as normalizeDiscordToken } from "./token-BZtonk7d.js";
|
|
2
3
|
import { a as mergeDiscordAccountConfig, s as resolveDiscordAccount } from "./accounts-CaHGiVB4.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { t as chunkDiscordTextWithMode } from "./chunk-DYl-_5RL.js";
|
|
5
|
+
import { t as parseAndResolveDiscordTarget } from "./target-resolver-DzOelJEt.js";
|
|
5
6
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
|
6
7
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
7
8
|
import { ChannelType, PermissionFlagsBits } from "discord-api-types/v10";
|
|
@@ -579,11 +580,24 @@ async function sendDiscordText(rest, channelId, text, replyTo, request, maxLines
|
|
|
579
580
|
});
|
|
580
581
|
return await request(() => createChannelMessage(rest, channelId, { body }), "text");
|
|
581
582
|
};
|
|
582
|
-
if (chunks.length === 1)
|
|
583
|
+
if (chunks.length === 1) {
|
|
584
|
+
const result = await sendChunk(chunks[0], true);
|
|
585
|
+
return {
|
|
586
|
+
...result,
|
|
587
|
+
platformMessageIds: result.id ? [result.id] : []
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
const platformMessageIds = [];
|
|
583
591
|
let last = null;
|
|
584
|
-
for (const [index, chunk] of chunks.entries())
|
|
592
|
+
for (const [index, chunk] of chunks.entries()) {
|
|
593
|
+
last = await sendChunk(chunk, index === 0);
|
|
594
|
+
if (last.id) platformMessageIds.push(last.id);
|
|
595
|
+
}
|
|
585
596
|
if (!last) throw new Error("Discord send failed (empty chunk result)");
|
|
586
|
-
return
|
|
597
|
+
return {
|
|
598
|
+
...last,
|
|
599
|
+
platformMessageIds
|
|
600
|
+
};
|
|
587
601
|
}
|
|
588
602
|
async function sendDiscordMedia(rest, channelId, text, mediaUrl, filename, mediaAccess, mediaLocalRoots, mediaReadFile, maxBytes, replyTo, request, maxLinesPerMessage, components, embeds, chunkMode, silent, maxChars) {
|
|
589
603
|
const media = await loadWebMedia(mediaUrl, buildOutboundMediaLoadOptions({
|
|
@@ -620,11 +634,16 @@ async function sendDiscordMedia(rest, channelId, text, mediaUrl, filename, media
|
|
|
620
634
|
}]
|
|
621
635
|
});
|
|
622
636
|
const res = await request(() => createChannelMessage(rest, channelId, { body }), "media");
|
|
637
|
+
const platformMessageIds = res.id ? [res.id] : [];
|
|
623
638
|
for (const chunk of chunks.slice(1)) {
|
|
624
639
|
if (!chunk.trim()) continue;
|
|
625
|
-
await sendDiscordText(rest, channelId, chunk, replyTo, request, maxLinesPerMessage, void 0, void 0, chunkMode, silent, maxChars);
|
|
640
|
+
const followup = await sendDiscordText(rest, channelId, chunk, replyTo, request, maxLinesPerMessage, void 0, void 0, chunkMode, silent, maxChars);
|
|
641
|
+
for (const id of followup.platformMessageIds) if (id) platformMessageIds.push(id);
|
|
626
642
|
}
|
|
627
|
-
return
|
|
643
|
+
return {
|
|
644
|
+
...res,
|
|
645
|
+
platformMessageIds
|
|
646
|
+
};
|
|
628
647
|
}
|
|
629
648
|
function buildReactionIdentifier(emoji) {
|
|
630
649
|
if (emoji.id && emoji.name) return `${emoji.name}:${emoji.id}`;
|
package/dist/session-key-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as normalizeExplicitDiscordSessionKey } from "./session-key-normalization-
|
|
1
|
+
import { t as normalizeExplicitDiscordSessionKey } from "./session-key-normalization-BQNCS1gu.js";
|
|
2
2
|
export { normalizeExplicitDiscordSessionKey };
|
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as discordSetupPlugin } from "./channel.setup-
|
|
1
|
+
import { t as discordSetupPlugin } from "./channel.setup-EQXuueIk.js";
|
|
2
2
|
export { discordSetupPlugin };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { a as mergeDiscordAccountConfig, c as resolveDiscordAccountAllowFrom, d as resolveDiscordAccountDmPolicy, n as isDiscordAccountEnabledForRuntime, o as resolveDefaultDiscordAccountId, r as listDiscordAccountIds, s as resolveDiscordAccount, u as resolveDiscordAccountDisabledReason } from "./accounts-CaHGiVB4.js";
|
|
2
2
|
import { t as inspectDiscordAccount } from "./account-inspect-BcQAxhKY.js";
|
|
3
3
|
import { i as getChatChannelMeta } from "./channel-api-CTSWMrnD.js";
|
|
4
|
-
import { t as DiscordChannelConfigSchema } from "./config-schema-
|
|
5
|
-
import { n as normalizeCompatibilityConfig } from "./doctor-contract-
|
|
6
|
-
import { t as DISCORD_LEGACY_CONFIG_RULES } from "./doctor-shared-
|
|
7
|
-
import { n as secretTargetRegistryEntries, t as collectRuntimeConfigAssignments } from "./secret-config-contract-
|
|
8
|
-
import { n as unsupportedSecretRefSurfacePatterns, t as collectUnsupportedSecretRefConfigCandidates } from "./security-contract-
|
|
9
|
-
import { t as deriveLegacySessionChatType } from "./session-contract-
|
|
4
|
+
import { t as DiscordChannelConfigSchema } from "./config-schema-BGn5I3_3.js";
|
|
5
|
+
import { n as normalizeCompatibilityConfig } from "./doctor-contract-BGjjFBdq.js";
|
|
6
|
+
import { t as DISCORD_LEGACY_CONFIG_RULES } from "./doctor-shared-D_QLzu30.js";
|
|
7
|
+
import { n as secretTargetRegistryEntries, t as collectRuntimeConfigAssignments } from "./secret-config-contract-BCQNNS7N.js";
|
|
8
|
+
import { n as unsupportedSecretRefSurfacePatterns, t as collectUnsupportedSecretRefConfigCandidates } from "./security-contract-DrbQqyyW.js";
|
|
9
|
+
import { t as deriveLegacySessionChatType } from "./session-contract-D871HDFG.js";
|
|
10
10
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
11
11
|
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
12
12
|
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter, createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
@@ -49,7 +49,7 @@ const collectDiscordSecurityWarnings = createOpenProviderConfiguredRouteWarningC
|
|
|
49
49
|
});
|
|
50
50
|
let discordSecurityAuditModulePromise;
|
|
51
51
|
async function loadDiscordSecurityAuditModule() {
|
|
52
|
-
discordSecurityAuditModulePromise ??= import("./security-audit.runtime-
|
|
52
|
+
discordSecurityAuditModulePromise ??= import("./security-audit.runtime-B7Gmz2DX.js");
|
|
53
53
|
return await discordSecurityAuditModulePromise;
|
|
54
54
|
}
|
|
55
55
|
const discordSecurityAdapter = {
|
|
@@ -69,7 +69,7 @@ const discordSetupAdapter = createEnvPatchedAccountSetupAdapter({
|
|
|
69
69
|
const DISCORD_CHANNEL = "discord";
|
|
70
70
|
let discordDoctorModulePromise;
|
|
71
71
|
async function loadDiscordDoctorModule() {
|
|
72
|
-
discordDoctorModulePromise ??= import("./doctor-
|
|
72
|
+
discordDoctorModulePromise ??= import("./doctor-CPV4Ch3V.js");
|
|
73
73
|
return await discordDoctorModulePromise;
|
|
74
74
|
}
|
|
75
75
|
const discordDoctor = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Pt as __exportAll } from "./discord-DtHMmZqJ.js";
|
|
2
|
+
import { presentationToInteractiveControlsReply, reduceInteractiveReply } from "openclaw/plugin-sdk/interactive-runtime";
|
|
3
3
|
//#region extensions/discord/src/shared-interactive.ts
|
|
4
4
|
var shared_interactive_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
buildDiscordInteractiveComponents: () => buildDiscordInteractiveComponents,
|
|
@@ -71,7 +71,7 @@ function buildDiscordPresentationComponents(presentation) {
|
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
const interactiveSpec = buildDiscordInteractiveComponents(
|
|
74
|
+
const interactiveSpec = buildDiscordInteractiveComponents(presentationToInteractiveControlsReply(presentation));
|
|
75
75
|
if (interactiveSpec?.blocks?.length) spec.blocks?.push(...interactiveSpec.blocks);
|
|
76
76
|
return spec.blocks?.length ? spec : void 0;
|
|
77
77
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Pt as __exportAll } from "./discord-DtHMmZqJ.js";
|
|
2
2
|
import { s as resolveDiscordAccount } from "./accounts-CaHGiVB4.js";
|
|
3
|
-
import { n as autoBindSpawnedDiscordSubagent, o as unbindThreadBindingsBySessionKey, r as listThreadBindingsBySessionKey } from "./thread-bindings-
|
|
3
|
+
import { n as autoBindSpawnedDiscordSubagent, o as unbindThreadBindingsBySessionKey, r as listThreadBindingsBySessionKey } from "./thread-bindings-DUzBL8jL.js";
|
|
4
4
|
import { normalizeOptionalLowercaseString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/text-runtime";
|
|
5
5
|
import { formatThreadBindingDisabledError, formatThreadBindingSpawnDisabledError, resolveThreadBindingSpawnPolicy } from "openclaw/plugin-sdk/conversation-runtime";
|
|
6
6
|
//#region extensions/discord/src/subagent-hooks.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region extensions/discord/subagent-hooks-api.ts
|
|
2
2
|
let discordSubagentHooksPromise = null;
|
|
3
3
|
function loadDiscordSubagentHooksModule() {
|
|
4
|
-
discordSubagentHooksPromise ??= import("./subagent-hooks-
|
|
4
|
+
discordSubagentHooksPromise ??= import("./subagent-hooks-BDy1pJD5.js").then((n) => n.i);
|
|
5
5
|
return discordSubagentHooksPromise;
|
|
6
6
|
}
|
|
7
7
|
function registerDiscordSubagentHooks(api) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as discord_exports } from "./discord-
|
|
1
|
+
import { t as discord_exports } from "./discord-DtHMmZqJ.js";
|
|
2
2
|
import { n as formatDiscordUserTag } from "./format-D8TsaXxW.js";
|
|
3
3
|
//#region extensions/discord/src/monitor/system-events.ts
|
|
4
4
|
function resolveDiscordSystemEvent(message, location) {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { buildMessagingTarget, parseMentionPrefixOrAtUserTarget, requireTargetKind } from "openclaw/plugin-sdk/messaging-targets";
|
|
2
|
+
//#region extensions/discord/src/target-parsing.ts
|
|
3
|
+
function parseDiscordTarget(raw, options = {}) {
|
|
4
|
+
const trimmed = raw.trim();
|
|
5
|
+
if (!trimmed) return;
|
|
6
|
+
const providerPrefixedTarget = parseDiscordProviderPrefixedTarget(trimmed);
|
|
7
|
+
if (providerPrefixedTarget) return providerPrefixedTarget;
|
|
8
|
+
const userTarget = parseMentionPrefixOrAtUserTarget({
|
|
9
|
+
raw: trimmed,
|
|
10
|
+
mentionPattern: /^<@!?(\d+)>$/,
|
|
11
|
+
prefixes: [
|
|
12
|
+
{
|
|
13
|
+
prefix: "user:",
|
|
14
|
+
kind: "user"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
prefix: "channel:",
|
|
18
|
+
kind: "channel"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
prefix: "discord:",
|
|
22
|
+
kind: "user"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
atUserPattern: /^\d+$/,
|
|
26
|
+
atUserErrorMessage: "Discord DMs require a user id (use user:<id> or a <@id> mention)"
|
|
27
|
+
});
|
|
28
|
+
if (userTarget) return userTarget;
|
|
29
|
+
if (/^\d+$/.test(trimmed)) {
|
|
30
|
+
if (options.defaultKind) return buildMessagingTarget(options.defaultKind, trimmed, trimmed);
|
|
31
|
+
throw new Error(options.ambiguousMessage ?? `Ambiguous Discord recipient "${trimmed}". For DMs use "user:${trimmed}" or "<@${trimmed}>"; for channels use "channel:${trimmed}".`);
|
|
32
|
+
}
|
|
33
|
+
return buildMessagingTarget("channel", trimmed, trimmed);
|
|
34
|
+
}
|
|
35
|
+
function parseDiscordProviderPrefixedTarget(raw) {
|
|
36
|
+
const match = /^discord:(channel|user):(.+)$/i.exec(raw);
|
|
37
|
+
if (!match) return;
|
|
38
|
+
const kind = match[1]?.toLowerCase();
|
|
39
|
+
const id = match[2]?.trim();
|
|
40
|
+
if (!kind || !id) return;
|
|
41
|
+
return buildMessagingTarget(kind, id, `${kind}:${id}`);
|
|
42
|
+
}
|
|
43
|
+
function resolveDiscordChannelId(raw) {
|
|
44
|
+
return requireTargetKind({
|
|
45
|
+
platform: "Discord",
|
|
46
|
+
target: parseDiscordTarget(raw, { defaultKind: "channel" }),
|
|
47
|
+
kind: "channel"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { resolveDiscordChannelId as n, parseDiscordTarget as t };
|