@kodelyth/discord 2026.5.39 → 2026.6.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.
Files changed (126) hide show
  1. package/dist/account-inspect-Dqw-enky.js +81 -0
  2. package/dist/account-inspect-api.js +10 -0
  3. package/dist/accounts-B7OBFePq.js +224 -0
  4. package/dist/action-runtime-api.js +2 -0
  5. package/dist/agent-components.runtime-DVY_1VB4.js +4 -0
  6. package/dist/allow-list-B0s7evD7.js +354 -0
  7. package/dist/api-CXAcv9nZ.js +130 -0
  8. package/dist/api.js +23 -0
  9. package/dist/approval-handler.runtime-B9xUAF3n.js +426 -0
  10. package/dist/audit-DoiK49WO.js +24 -0
  11. package/dist/audit-core-BGrq3G7r.js +105 -0
  12. package/dist/channel-U_aeoFwW.js +795 -0
  13. package/dist/channel-actions-BxEBnEuv.js +173 -0
  14. package/dist/channel-actions.runtime-CPtpH-yl.js +263 -0
  15. package/dist/channel-api-BfjklLby.js +21 -0
  16. package/dist/channel-config-api.js +2 -0
  17. package/dist/channel-plugin-api.js +2 -0
  18. package/dist/channel.setup-BUSC0apv.js +337 -0
  19. package/dist/components-luonoe13.js +909 -0
  20. package/dist/config-api-DSYGqaLQ.js +2 -0
  21. package/dist/config-schema-DIqJBGwC.js +357 -0
  22. package/dist/configured-state.js +6 -0
  23. package/dist/contract-api.js +8 -0
  24. package/dist/conversation-identity-DXAm0_Mk.js +270 -0
  25. package/dist/directory-config-CYbuMmPS.js +49 -0
  26. package/dist/directory-contract-api.js +2 -0
  27. package/dist/directory-live-DX4dLRpJ.js +159 -0
  28. package/dist/doctor-bbKSvGVD.js +244 -0
  29. package/dist/doctor-contract-Btjt6NJD.js +383 -0
  30. package/dist/doctor-contract-api.js +2 -0
  31. package/dist/gateway-registry-BKSpa4GB.js +74 -0
  32. package/dist/handle-action.guild-admin-B5BArS2n.js +286 -0
  33. package/dist/inbound-context-WAOqhGlT.js +48 -0
  34. package/dist/inbound-event-delivery-C-1Ji3WP.js +65 -0
  35. package/dist/index.js +26 -0
  36. package/dist/manager.runtime-DXHynKE4.js +2356 -0
  37. package/dist/message-handler-mXzc3tA_.js +381 -0
  38. package/dist/message-handler.preflight-BPD1a347.js +1113 -0
  39. package/dist/message-handler.process-GUa3aV8z.js +1438 -0
  40. package/dist/message-utils-dUbem16p.js +549 -0
  41. package/dist/outbound-adapter-C18OAc1y.js +536 -0
  42. package/dist/pluralkit-D1Q2x0w5.js +22 -0
  43. package/dist/preflight-audio-CZtpWcIm.js +72 -0
  44. package/dist/preflight-audio.runtime-Brx_0_xW.js +7 -0
  45. package/dist/preview-streaming-D_slNIiO.js +8 -0
  46. package/dist/probe-D--Ca4JF.js +139 -0
  47. package/dist/probe.runtime-DQBchZzv.js +2 -0
  48. package/dist/provider-B2-31CIT.js +9565 -0
  49. package/dist/provider-session.runtime-BwzzSsrH.js +6 -0
  50. package/dist/provider.runtime-CP3oHLls.js +2 -0
  51. package/dist/resolve-allowlist-common-CqxPLcJO.js +34 -0
  52. package/dist/resolve-channels-0LX4pUbB.js +265 -0
  53. package/dist/resolve-users-CztOv0Qs.js +120 -0
  54. package/dist/runtime-DUaw66V_.js +1073 -0
  55. package/dist/runtime-api.actions.js +3 -0
  56. package/dist/runtime-api.js +30 -0
  57. package/dist/runtime-api.lookup.js +7 -0
  58. package/dist/runtime-api.monitor-CvVKvEXW.js +5 -0
  59. package/dist/runtime-api.monitor.js +8 -0
  60. package/dist/runtime-api.send.js +6 -0
  61. package/dist/runtime-api.threads.js +6 -0
  62. package/dist/runtime-fC6f4UF2.js +8 -0
  63. package/dist/runtime-setter-api.js +2 -0
  64. package/dist/secret-config-contract-B6WW5V88.js +115 -0
  65. package/dist/secret-contract-api.js +2 -0
  66. package/dist/security-audit-CnyIQKz6.js +120 -0
  67. package/dist/security-audit-contract-api.js +2 -0
  68. package/dist/security-audit.runtime-CQSkjNLu.js +2 -0
  69. package/dist/security-contract-DLvYOgLM.js +26 -0
  70. package/dist/security-contract-api.js +2 -0
  71. package/dist/security-doctor-DepqtNCI.js +18 -0
  72. package/dist/send-DCtPCHGk.js +881 -0
  73. package/dist/send.components-Bcgxvm52.js +474 -0
  74. package/dist/send.outbound-S9t0UuHc.js +330 -0
  75. package/dist/send.receipt-CDn3GBWC.js +3119 -0
  76. package/dist/send.shared-D4iBnAmn.js +669 -0
  77. package/dist/sender-identity-CxCe3_1a.js +43 -0
  78. package/dist/session-contract-Dwhw3RTY.js +6 -0
  79. package/dist/session-key-api.js +2 -0
  80. package/dist/session-key-normalization-CP8dPUid.js +23 -0
  81. package/dist/setup-entry.js +11 -0
  82. package/dist/setup-plugin-api.js +2 -0
  83. package/dist/shared-AIlvuZXt.js +171 -0
  84. package/dist/subagent-hooks-8bK-mgiU.js +120 -0
  85. package/dist/subagent-hooks-api.js +22 -0
  86. package/dist/system-events-Ba1TklaL.js +34 -0
  87. package/dist/target-resolver-BrtFQtoK.js +82 -0
  88. package/dist/targets-DWLLZE2l.js +3 -0
  89. package/dist/test-api.js +45 -0
  90. package/dist/thread-binding-api.js +4 -0
  91. package/dist/thread-bindings-9aKRmZv0.js +255 -0
  92. package/dist/thread-bindings.discord-api-ssGH5wc2.js +244 -0
  93. package/dist/thread-bindings.manager-0YBHGemk.js +534 -0
  94. package/dist/thread-bindings.session-updates-DJZGIwaU.js +54 -0
  95. package/dist/thread-bindings.state-eTFl-PqJ.js +318 -0
  96. package/dist/timeouts-CEwuGaWT.js +52 -0
  97. package/dist/timeouts.js +2 -0
  98. package/dist/typing-BmJKRpCS.js +14 -0
  99. package/package.json +19 -7
  100. package/account-inspect-api.js +0 -7
  101. package/action-runtime-api.js +0 -7
  102. package/api.js +0 -7
  103. package/channel-config-api.js +0 -7
  104. package/channel-plugin-api.js +0 -7
  105. package/configured-state.js +0 -7
  106. package/contract-api.js +0 -7
  107. package/directory-contract-api.js +0 -7
  108. package/doctor-contract-api.js +0 -7
  109. package/index.js +0 -7
  110. package/runtime-api.actions.js +0 -7
  111. package/runtime-api.js +0 -7
  112. package/runtime-api.lookup.js +0 -7
  113. package/runtime-api.monitor.js +0 -7
  114. package/runtime-api.send.js +0 -7
  115. package/runtime-api.threads.js +0 -7
  116. package/runtime-setter-api.js +0 -7
  117. package/secret-contract-api.js +0 -7
  118. package/security-audit-contract-api.js +0 -7
  119. package/security-contract-api.js +0 -7
  120. package/session-key-api.js +0 -7
  121. package/setup-entry.js +0 -7
  122. package/setup-plugin-api.js +0 -7
  123. package/subagent-hooks-api.js +0 -7
  124. package/test-api.js +0 -7
  125. package/thread-binding-api.js +0 -7
  126. package/timeouts.js +0 -7
@@ -0,0 +1,330 @@
1
+ import { ct as createThread, n as createDiscordSendResult, st as createChannelMessage } from "./send.receipt-CDn3GBWC.js";
2
+ import { s as resolveDiscordAccount } from "./accounts-B7OBFePq.js";
3
+ import { M as createDiscordClient, _ as resolveDiscordMessageFlags, a as normalizeDiscordPollInput, c as normalizeStickerIds, f as sendDiscordMedia, g as buildDiscordMessageRequest, j as parseAndResolveRecipient, l as resolveChannelId, n as buildDiscordTextChunks, p as sendDiscordText, t as buildDiscordSendError, u as resolveDiscordChannelType, v as resolveDiscordSendComponents, y as resolveDiscordSendEmbeds } from "./send.shared-D4iBnAmn.js";
4
+ import { a as resolveDiscordDirectoryUserId } from "./directory-live-DX4dLRpJ.js";
5
+ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "klaw/plugin-sdk/string-coerce-runtime";
6
+ import { ChannelType } from "discord-api-types/v10";
7
+ import { requireRuntimeConfig } from "klaw/plugin-sdk/plugin-config-runtime";
8
+ import { resolveChunkMode } from "klaw/plugin-sdk/reply-chunking";
9
+ import { recordChannelActivity } from "klaw/plugin-sdk/channel-activity-runtime";
10
+ import { resolveMarkdownTableMode } from "klaw/plugin-sdk/markdown-table-runtime";
11
+ import { convertMarkdownTables } from "klaw/plugin-sdk/text-chunking";
12
+ //#region extensions/discord/src/mentions.ts
13
+ const MARKDOWN_CODE_SEGMENT_PATTERN = /```[\s\S]*?```|`[^`\n]*`/g;
14
+ const MENTION_CANDIDATE_PATTERN = /(^|[\s([{"'.,;:!?])@([a-z0-9_.-]{2,32}(?:#[0-9]{4})?)/gi;
15
+ const DISCORD_RESERVED_MENTIONS = new Set(["everyone", "here"]);
16
+ const DISCORD_DISCRIMINATOR_SUFFIX = /#\d{4}$/;
17
+ function normalizeSnowflake(value) {
18
+ const text = normalizeOptionalStringifiedId(value) ?? "";
19
+ if (!/^\d+$/.test(text)) return null;
20
+ return text;
21
+ }
22
+ function formatMention(params) {
23
+ const userId = params.userId == null ? null : normalizeSnowflake(params.userId);
24
+ const roleId = params.roleId == null ? null : normalizeSnowflake(params.roleId);
25
+ const channelId = params.channelId == null ? null : normalizeSnowflake(params.channelId);
26
+ const values = [
27
+ userId ? {
28
+ kind: "user",
29
+ id: userId
30
+ } : null,
31
+ roleId ? {
32
+ kind: "role",
33
+ id: roleId
34
+ } : null,
35
+ channelId ? {
36
+ kind: "channel",
37
+ id: channelId
38
+ } : null
39
+ ].filter((entry) => Boolean(entry));
40
+ if (values.length !== 1) throw new Error("formatMention requires exactly one of userId, roleId, or channelId");
41
+ const target = values[0];
42
+ if (target.kind === "user") return `<@${target.id}>`;
43
+ if (target.kind === "role") return `<@&${target.id}>`;
44
+ return `<#${target.id}>`;
45
+ }
46
+ function normalizeHandleKey(raw) {
47
+ let handle = normalizeOptionalString(raw) ?? "";
48
+ if (!handle) return null;
49
+ if (handle.startsWith("@")) handle = normalizeOptionalString(handle.slice(1)) ?? "";
50
+ if (!handle || /\s/.test(handle)) return null;
51
+ return normalizeLowercaseStringOrEmpty(handle);
52
+ }
53
+ function resolveConfiguredMentionAlias(handle, mentionAliases) {
54
+ const key = normalizeHandleKey(handle);
55
+ if (!key || !mentionAliases) return;
56
+ const withoutDiscriminator = key.replace(DISCORD_DISCRIMINATOR_SUFFIX, "");
57
+ for (const [rawAlias, rawUserId] of Object.entries(mentionAliases)) {
58
+ const alias = normalizeHandleKey(rawAlias);
59
+ if (!alias) continue;
60
+ const aliasWithoutDiscriminator = alias.replace(DISCORD_DISCRIMINATOR_SUFFIX, "");
61
+ if (alias === key || withoutDiscriminator && withoutDiscriminator !== key && alias === withoutDiscriminator || aliasWithoutDiscriminator && aliasWithoutDiscriminator !== alias && aliasWithoutDiscriminator === key) {
62
+ const userId = normalizeSnowflake(rawUserId);
63
+ if (userId) return userId;
64
+ }
65
+ }
66
+ }
67
+ function rewritePlainTextMentions(text, params) {
68
+ if (!text.includes("@")) return text;
69
+ return text.replace(MENTION_CANDIDATE_PATTERN, (match, prefix, rawHandle) => {
70
+ const handle = normalizeOptionalString(rawHandle) ?? "";
71
+ if (!handle) return match;
72
+ const lookup = normalizeLowercaseStringOrEmpty(handle);
73
+ if (DISCORD_RESERVED_MENTIONS.has(lookup)) return match;
74
+ const userId = resolveConfiguredMentionAlias(handle, params.mentionAliases) ?? resolveDiscordDirectoryUserId({
75
+ accountId: params.accountId,
76
+ handle
77
+ });
78
+ if (!userId) return match;
79
+ return `${String(prefix ?? "")}${formatMention({ userId })}`;
80
+ });
81
+ }
82
+ function rewriteDiscordKnownMentions(text, params) {
83
+ if (!text.includes("@")) return text;
84
+ let rewritten = "";
85
+ let offset = 0;
86
+ MARKDOWN_CODE_SEGMENT_PATTERN.lastIndex = 0;
87
+ for (const match of text.matchAll(MARKDOWN_CODE_SEGMENT_PATTERN)) {
88
+ const matchIndex = match.index ?? 0;
89
+ rewritten += rewritePlainTextMentions(text.slice(offset, matchIndex), params);
90
+ rewritten += match[0];
91
+ offset = matchIndex + match[0].length;
92
+ }
93
+ rewritten += rewritePlainTextMentions(text.slice(offset), params);
94
+ return rewritten;
95
+ }
96
+ //#endregion
97
+ //#region extensions/discord/src/send.outbound.ts
98
+ const DEFAULT_DISCORD_MEDIA_MAX_MB = 100;
99
+ async function sendDiscordThreadTextChunks(params) {
100
+ for (const chunk of params.chunks) await sendDiscordText(params.rest, params.threadId, chunk, void 0, params.request, params.maxLinesPerMessage, void 0, void 0, params.chunkMode, params.silent, params.suppressEmbeds, params.maxChars);
101
+ }
102
+ function resolveDiscordSuppressEmbeds(params) {
103
+ return params.override ?? params.configured ?? true;
104
+ }
105
+ /** Discord thread names are capped at 100 characters. */
106
+ const DISCORD_THREAD_NAME_LIMIT = 100;
107
+ /** Derive a thread title from the first non-empty line of the message text. */
108
+ function deriveForumThreadName(text) {
109
+ return (normalizeOptionalString(text.split("\n").find((line) => normalizeOptionalString(line))) ?? "").slice(0, DISCORD_THREAD_NAME_LIMIT) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 16);
110
+ }
111
+ /** Forum/Media channels cannot receive regular messages; detect them here. */
112
+ function isForumLikeType(channelType) {
113
+ return channelType === ChannelType.GuildForum || channelType === ChannelType.GuildMedia;
114
+ }
115
+ function toDiscordSendResult(result, fallbackChannelId, params = {}) {
116
+ const resultParams = {
117
+ result,
118
+ fallbackChannelId,
119
+ kind: params.kind ?? "text"
120
+ };
121
+ if (params.threadId != null) resultParams.threadId = params.threadId;
122
+ if (params.replyToId) resultParams.replyToId = params.replyToId;
123
+ return createDiscordSendResult(resultParams);
124
+ }
125
+ async function resolveDiscordSendTarget(to, opts) {
126
+ const cfg = requireRuntimeConfig(opts.cfg, "Discord send target resolution");
127
+ const { rest, request } = createDiscordClient({
128
+ ...opts,
129
+ cfg
130
+ });
131
+ const { channelId } = await resolveChannelId(rest, await parseAndResolveRecipient(to, cfg, opts.accountId), request);
132
+ return {
133
+ rest,
134
+ request,
135
+ channelId
136
+ };
137
+ }
138
+ async function sendMessageDiscord(to, text, opts) {
139
+ const cfg = requireRuntimeConfig(opts.cfg, "Discord send");
140
+ const accountInfo = resolveDiscordAccount({
141
+ cfg,
142
+ accountId: opts.accountId
143
+ });
144
+ const tableMode = resolveMarkdownTableMode({
145
+ cfg,
146
+ channel: "discord",
147
+ accountId: accountInfo.accountId
148
+ });
149
+ const effectiveTableMode = opts.tableMode ?? tableMode;
150
+ const chunkMode = opts.chunkMode ?? resolveChunkMode(cfg, "discord", accountInfo.accountId);
151
+ const maxLinesPerMessage = opts.maxLinesPerMessage ?? accountInfo.config.maxLinesPerMessage;
152
+ const suppressEmbeds = resolveDiscordSuppressEmbeds({
153
+ configured: accountInfo.config.suppressEmbeds,
154
+ override: opts.suppressEmbeds
155
+ });
156
+ const textLimit = typeof opts.textLimit === "number" && Number.isFinite(opts.textLimit) ? Math.max(1, Math.min(Math.floor(opts.textLimit), 2e3)) : void 0;
157
+ const mediaMaxBytes = typeof accountInfo.config.mediaMaxMb === "number" ? accountInfo.config.mediaMaxMb * 1024 * 1024 : DEFAULT_DISCORD_MEDIA_MAX_MB * 1024 * 1024;
158
+ const textWithTables = convertMarkdownTables(text ?? "", effectiveTableMode);
159
+ const textWithMentions = rewriteDiscordKnownMentions(textWithTables, {
160
+ accountId: accountInfo.accountId,
161
+ mentionAliases: accountInfo.config.mentionAliases
162
+ });
163
+ const { token, rest, request } = createDiscordClient({
164
+ ...opts,
165
+ cfg
166
+ });
167
+ const { channelId } = await resolveChannelId(rest, await parseAndResolveRecipient(to, cfg, opts.accountId), request);
168
+ if (isForumLikeType(await resolveDiscordChannelType(rest, channelId))) {
169
+ const threadName = deriveForumThreadName(textWithTables);
170
+ const chunks = buildDiscordTextChunks(textWithMentions, {
171
+ maxLinesPerMessage,
172
+ chunkMode,
173
+ maxChars: textLimit
174
+ });
175
+ const starterContent = chunks[0]?.trim() ? chunks[0] : threadName;
176
+ const starterComponents = resolveDiscordSendComponents({
177
+ components: opts.components,
178
+ text: starterContent,
179
+ isFirst: true
180
+ });
181
+ const starterEmbeds = resolveDiscordSendEmbeds({
182
+ embeds: opts.embeds,
183
+ isFirst: true
184
+ });
185
+ const starterBody = buildDiscordMessageRequest({
186
+ text: starterContent,
187
+ components: starterComponents,
188
+ embeds: starterEmbeds,
189
+ flags: resolveDiscordMessageFlags({
190
+ silent: opts.silent,
191
+ suppressEmbeds: suppressEmbeds && !starterEmbeds?.length
192
+ })
193
+ });
194
+ let threadRes;
195
+ try {
196
+ threadRes = await request(() => createThread(rest, channelId, { body: {
197
+ name: threadName,
198
+ message: starterBody
199
+ } }), "forum-thread");
200
+ } catch (err) {
201
+ throw await buildDiscordSendError(err, {
202
+ channelId,
203
+ cfg,
204
+ rest,
205
+ token,
206
+ hasMedia: Boolean(opts.mediaUrl)
207
+ });
208
+ }
209
+ const threadId = threadRes.id;
210
+ const messageId = threadRes.message?.id ?? threadId;
211
+ const resultChannelId = threadRes.message?.channel_id ?? threadId;
212
+ const remainingChunks = chunks.slice(1);
213
+ try {
214
+ if (opts.mediaUrl) {
215
+ const [mediaCaption, ...afterMediaChunks] = remainingChunks;
216
+ await sendDiscordMedia(rest, threadId, mediaCaption ?? "", opts.mediaUrl, opts.filename, opts.mediaAccess, opts.mediaLocalRoots, opts.mediaReadFile, mediaMaxBytes, void 0, request, maxLinesPerMessage, void 0, void 0, chunkMode, opts.silent, suppressEmbeds, textLimit);
217
+ await sendDiscordThreadTextChunks({
218
+ rest,
219
+ threadId,
220
+ chunks: afterMediaChunks,
221
+ request,
222
+ maxLinesPerMessage,
223
+ chunkMode,
224
+ maxChars: textLimit,
225
+ silent: opts.silent,
226
+ suppressEmbeds
227
+ });
228
+ } else await sendDiscordThreadTextChunks({
229
+ rest,
230
+ threadId,
231
+ chunks: remainingChunks,
232
+ request,
233
+ maxLinesPerMessage,
234
+ chunkMode,
235
+ maxChars: textLimit,
236
+ silent: opts.silent,
237
+ suppressEmbeds
238
+ });
239
+ } catch (err) {
240
+ throw await buildDiscordSendError(err, {
241
+ channelId: threadId,
242
+ cfg,
243
+ rest,
244
+ token,
245
+ hasMedia: Boolean(opts.mediaUrl)
246
+ });
247
+ }
248
+ recordChannelActivity({
249
+ channel: "discord",
250
+ accountId: accountInfo.accountId,
251
+ direction: "outbound"
252
+ });
253
+ return toDiscordSendResult({
254
+ id: messageId,
255
+ channel_id: resultChannelId
256
+ }, channelId, {
257
+ kind: opts.mediaUrl ? "media" : "text",
258
+ threadId
259
+ });
260
+ }
261
+ let result;
262
+ try {
263
+ if (opts.mediaUrl) result = await sendDiscordMedia(rest, channelId, textWithMentions, opts.mediaUrl, opts.filename, opts.mediaAccess, opts.mediaLocalRoots, opts.mediaReadFile, mediaMaxBytes, opts.replyTo, request, maxLinesPerMessage, opts.components, opts.embeds, chunkMode, opts.silent, suppressEmbeds, textLimit);
264
+ else result = await sendDiscordText(rest, channelId, textWithMentions, opts.replyTo, request, maxLinesPerMessage, opts.components, opts.embeds, chunkMode, opts.silent, suppressEmbeds, textLimit);
265
+ } catch (err) {
266
+ throw await buildDiscordSendError(err, {
267
+ channelId,
268
+ cfg,
269
+ rest,
270
+ token,
271
+ hasMedia: Boolean(opts.mediaUrl)
272
+ });
273
+ }
274
+ recordChannelActivity({
275
+ channel: "discord",
276
+ accountId: accountInfo.accountId,
277
+ direction: "outbound"
278
+ });
279
+ return toDiscordSendResult(result, channelId, {
280
+ kind: opts.mediaUrl ? "media" : opts.components || opts.embeds ? "card" : "text",
281
+ replyToId: opts.replyTo
282
+ });
283
+ }
284
+ async function sendStickerDiscord(to, stickerIds, opts) {
285
+ const { rest, request, channelId, rewrittenContent, suppressEmbeds } = await resolveDiscordStructuredSendContext(to, opts);
286
+ const stickers = normalizeStickerIds(stickerIds);
287
+ const flags = resolveDiscordMessageFlags({ suppressEmbeds });
288
+ return toDiscordSendResult(await request(() => createChannelMessage(rest, channelId, { body: {
289
+ content: rewrittenContent || void 0,
290
+ sticker_ids: stickers,
291
+ ...flags ? { flags } : {}
292
+ } }), "sticker"), channelId, { kind: "card" });
293
+ }
294
+ async function sendPollDiscord(to, poll, opts) {
295
+ const { rest, request, channelId, rewrittenContent, suppressEmbeds } = await resolveDiscordStructuredSendContext(to, opts);
296
+ if (poll.durationSeconds !== void 0) throw new Error("Discord polls do not support durationSeconds; use durationHours");
297
+ const payload = normalizeDiscordPollInput(poll);
298
+ const flags = resolveDiscordMessageFlags({
299
+ silent: opts.silent,
300
+ suppressEmbeds
301
+ });
302
+ return toDiscordSendResult(await request(() => createChannelMessage(rest, channelId, { body: {
303
+ content: rewrittenContent || void 0,
304
+ poll: payload,
305
+ ...flags ? { flags } : {}
306
+ } }), "poll"), channelId, { kind: "card" });
307
+ }
308
+ async function resolveDiscordStructuredSendContext(to, opts) {
309
+ const accountInfo = resolveDiscordAccount({
310
+ cfg: requireRuntimeConfig(opts.cfg, "Discord structured send"),
311
+ accountId: opts.accountId
312
+ });
313
+ const { rest, request, channelId } = await resolveDiscordSendTarget(to, opts);
314
+ const content = opts.content?.trim();
315
+ return {
316
+ rest,
317
+ request,
318
+ channelId,
319
+ rewrittenContent: content ? rewriteDiscordKnownMentions(content, {
320
+ accountId: accountInfo.accountId,
321
+ mentionAliases: accountInfo.config.mentionAliases
322
+ }) : void 0,
323
+ suppressEmbeds: resolveDiscordSuppressEmbeds({
324
+ configured: accountInfo.config.suppressEmbeds,
325
+ override: opts.suppressEmbeds
326
+ })
327
+ };
328
+ }
329
+ //#endregion
330
+ export { rewriteDiscordKnownMentions as a, formatMention as i, sendPollDiscord as n, sendStickerDiscord as r, sendMessageDiscord as t };