shardwire 1.3.0 → 1.4.5
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/README.md +36 -4
- package/dist/index.d.mts +220 -2
- package/dist/index.d.ts +220 -2
- package/dist/index.js +721 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +717 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,7 +106,7 @@ app.on(
|
|
|
106
106
|
## Startup lifecycle
|
|
107
107
|
|
|
108
108
|
- **`createBotBridge(...)`** starts the WebSocket server immediately; `await bridge.ready()` resolves when the Discord client has finished its initial `ready` handshake (same timing you would expect from a normal bot login).
|
|
109
|
-
- **Register `app.on(...)` handlers before `await app.ready()`** so subscriptions are known when the app authenticates. `ready()` connects, completes auth, negotiates capabilities from intents + secret scope, then throws `BridgeCapabilityError` if any registered handler targets an event the app is not allowed to receive.
|
|
109
|
+
- **Register `app.on(...)` handlers before `await app.ready()`** so subscriptions are known when the app authenticates. `ready()` connects, completes auth, negotiates capabilities from intents + secret scope, then throws `BridgeCapabilityError` if any registered handler targets an event the app is not allowed to receive. To probe connectivity and negotiated caps first (and validate a planned surface with `desired`), use **`await app.preflight(desired)`** before registering handlers.
|
|
110
110
|
- **Sticky `ready`**: if the bot was already ready before the app connected, the bridge replays the latest `ready` payload to matching subscriptions after auth.
|
|
111
111
|
|
|
112
112
|
## Built-In Events
|
|
@@ -118,6 +118,7 @@ Apps subscribe to events with `app.on(...)`. The bridge forwards only what each
|
|
|
118
118
|
- `messageCreate`
|
|
119
119
|
- `messageUpdate`
|
|
120
120
|
- `messageDelete`
|
|
121
|
+
- `messageBulkDelete`
|
|
121
122
|
- `messageReactionAdd`
|
|
122
123
|
- `messageReactionRemove`
|
|
123
124
|
- `guildCreate`
|
|
@@ -128,6 +129,9 @@ Apps subscribe to events with `app.on(...)`. The bridge forwards only what each
|
|
|
128
129
|
- `threadCreate`
|
|
129
130
|
- `threadUpdate`
|
|
130
131
|
- `threadDelete`
|
|
132
|
+
- `channelCreate`
|
|
133
|
+
- `channelUpdate`
|
|
134
|
+
- `channelDelete`
|
|
131
135
|
|
|
132
136
|
Supported filters:
|
|
133
137
|
|
|
@@ -137,13 +141,16 @@ Supported filters:
|
|
|
137
141
|
- `commandName` (for `interactionCreate`)
|
|
138
142
|
- `customId` (for `interactionCreate`)
|
|
139
143
|
- `interactionKind` (for `interactionCreate`)
|
|
144
|
+
- `channelType` (Discord `ChannelType` when present on the payload, for example `messageCreate` / `messageBulkDelete`)
|
|
145
|
+
- `parentChannelId` (category parent, forum/text parent for threads, or thread parent when serialized)
|
|
146
|
+
- `threadId` (guild thread channels only: matches thread channel ids)
|
|
140
147
|
|
|
141
148
|
### Intent Notes
|
|
142
149
|
|
|
143
150
|
- `ready` and `interactionCreate`: no specific event intent requirement
|
|
144
|
-
- `messageCreate`, `messageUpdate`, `messageDelete`: `GuildMessages`
|
|
151
|
+
- `messageCreate`, `messageUpdate`, `messageDelete`, `messageBulkDelete`: `GuildMessages`
|
|
145
152
|
- `messageReactionAdd`, `messageReactionRemove`: `GuildMessageReactions`
|
|
146
|
-
- `guildCreate`, `guildDelete`, `threadCreate`, `threadUpdate`, `threadDelete`: `Guilds`
|
|
153
|
+
- `guildCreate`, `guildDelete`, `threadCreate`, `threadUpdate`, `threadDelete`, `channelCreate`, `channelUpdate`, `channelDelete`: `Guilds`
|
|
147
154
|
- `guildMemberAdd`, `guildMemberRemove`, `guildMemberUpdate`: `GuildMembers`
|
|
148
155
|
|
|
149
156
|
## Built-In Actions
|
|
@@ -169,6 +176,13 @@ Supported filters:
|
|
|
169
176
|
- `removeMemberRole`
|
|
170
177
|
- `addMessageReaction`
|
|
171
178
|
- `removeOwnMessageReaction`
|
|
179
|
+
- `timeoutMember`
|
|
180
|
+
- `removeMemberTimeout`
|
|
181
|
+
- `createChannel`
|
|
182
|
+
- `editChannel`
|
|
183
|
+
- `deleteChannel`
|
|
184
|
+
- `createThread`
|
|
185
|
+
- `archiveThread`
|
|
172
186
|
|
|
173
187
|
All actions return:
|
|
174
188
|
|
|
@@ -256,6 +270,16 @@ const capabilities = app.capabilities();
|
|
|
256
270
|
console.log(capabilities.events, capabilities.actions);
|
|
257
271
|
```
|
|
258
272
|
|
|
273
|
+
### Discovery, preflight, and workflow helpers
|
|
274
|
+
|
|
275
|
+
- **`app.catalog()`** — static list of built-in events (with required gateway intents), actions, and subscription filter keys (no connection required).
|
|
276
|
+
- **`getShardwireCatalog()`** — same data without an `AppBridge` instance.
|
|
277
|
+
- **`app.explainCapability({ kind: 'event' | 'action', name })`** — whether a name is built-in and, after connect, whether the negotiated bridge allows it.
|
|
278
|
+
- **`app.preflight(desired?)`** — awaits auth, returns `issues[]` (errors/warnings) for transport hints, `desired` vs negotiated caps, and subscription/capability mismatches. Prefer calling **before** `app.on(...)` if you want to validate `desired.events` / `desired.actions` without registering handlers yet.
|
|
279
|
+
- **Workflows** — `deferThenEditInteractionReply`, `deferUpdateThenEditInteractionReply`, `createThreadThenSendMessage` chain common action sequences.
|
|
280
|
+
|
|
281
|
+
`FORBIDDEN` results for actions outside negotiated capabilities include `error.details.reasonCode === 'action_not_in_capabilities'`. `BridgeCapabilityError` from `ready()` / `on()` may include `details.requiredIntents` for disallowed event subscriptions.
|
|
282
|
+
|
|
259
283
|
## Run the Included Examples
|
|
260
284
|
|
|
261
285
|
### Minimal (single shared secret)
|
|
@@ -305,13 +329,21 @@ SHARDWIRE_SECRET_MODERATION=moderation-secret \
|
|
|
305
329
|
## Public API
|
|
306
330
|
|
|
307
331
|
```ts
|
|
308
|
-
import {
|
|
332
|
+
import {
|
|
333
|
+
connectBotBridge,
|
|
334
|
+
createBotBridge,
|
|
335
|
+
createThreadThenSendMessage,
|
|
336
|
+
deferThenEditInteractionReply,
|
|
337
|
+
getShardwireCatalog,
|
|
338
|
+
} from 'shardwire';
|
|
309
339
|
```
|
|
310
340
|
|
|
311
341
|
Main exports include:
|
|
312
342
|
|
|
313
343
|
- `createBotBridge(options)`
|
|
314
344
|
- `connectBotBridge(options)`
|
|
345
|
+
- `getShardwireCatalog()`
|
|
346
|
+
- `deferThenEditInteractionReply`, `deferUpdateThenEditInteractionReply`, `createThreadThenSendMessage`
|
|
315
347
|
- `BridgeCapabilityError`
|
|
316
348
|
- bot/app option types
|
|
317
349
|
- normalized event payload types (for example `BridgeMessage`, `BridgeInteraction`, `BridgeGuildMember`)
|
package/dist/index.d.mts
CHANGED
|
@@ -59,6 +59,14 @@ interface BridgeThread {
|
|
|
59
59
|
archived?: boolean;
|
|
60
60
|
locked?: boolean;
|
|
61
61
|
}
|
|
62
|
+
/** Normalized non-thread channel snapshot for channel lifecycle events. */
|
|
63
|
+
interface BridgeChannel {
|
|
64
|
+
id: Snowflake;
|
|
65
|
+
type: number;
|
|
66
|
+
name?: string | null;
|
|
67
|
+
guildId?: Snowflake;
|
|
68
|
+
parentId?: Snowflake | null;
|
|
69
|
+
}
|
|
62
70
|
interface BridgeMessage {
|
|
63
71
|
id: Snowflake;
|
|
64
72
|
channelId: Snowflake;
|
|
@@ -73,12 +81,18 @@ interface BridgeMessage {
|
|
|
73
81
|
/** Message component rows (JSON-serializable API shape). */
|
|
74
82
|
components?: APIActionRowComponent<APIComponentInMessageActionRow>[];
|
|
75
83
|
reference?: BridgeMessageReference;
|
|
84
|
+
/** Discord `ChannelType` when the runtime could resolve `message.channel`. */
|
|
85
|
+
channelType?: number;
|
|
86
|
+
/** Parent category (guild text channels) or parent text/forum (threads), when known. */
|
|
87
|
+
parentChannelId?: Snowflake;
|
|
76
88
|
}
|
|
77
89
|
interface BridgeDeletedMessage {
|
|
78
90
|
id: Snowflake;
|
|
79
91
|
channelId: Snowflake;
|
|
80
92
|
guildId?: Snowflake;
|
|
81
93
|
deletedAt: string;
|
|
94
|
+
channelType?: number;
|
|
95
|
+
parentChannelId?: Snowflake;
|
|
82
96
|
}
|
|
83
97
|
interface BridgeReactionEmoji {
|
|
84
98
|
id?: Snowflake;
|
|
@@ -99,6 +113,10 @@ interface BridgeInteraction {
|
|
|
99
113
|
kind: BridgeInteractionKind;
|
|
100
114
|
guildId?: Snowflake;
|
|
101
115
|
channelId?: Snowflake;
|
|
116
|
+
/** Discord `ChannelType` for `channelId` when the runtime resolved the channel. */
|
|
117
|
+
channelType?: number;
|
|
118
|
+
/** Parent category or parent text/forum for thread channels, when known. */
|
|
119
|
+
parentChannelId?: Snowflake;
|
|
102
120
|
user: BridgeUser;
|
|
103
121
|
member?: BridgeGuildMember;
|
|
104
122
|
commandName?: string;
|
|
@@ -161,12 +179,32 @@ interface MessageReactionAddEventPayload extends EventEnvelopeBase {
|
|
|
161
179
|
interface MessageReactionRemoveEventPayload extends EventEnvelopeBase {
|
|
162
180
|
reaction: BridgeMessageReaction;
|
|
163
181
|
}
|
|
182
|
+
interface ChannelCreateEventPayload extends EventEnvelopeBase {
|
|
183
|
+
channel: BridgeChannel;
|
|
184
|
+
}
|
|
185
|
+
interface ChannelUpdateEventPayload extends EventEnvelopeBase {
|
|
186
|
+
oldChannel?: BridgeChannel;
|
|
187
|
+
channel: BridgeChannel;
|
|
188
|
+
}
|
|
189
|
+
interface ChannelDeleteEventPayload extends EventEnvelopeBase {
|
|
190
|
+
channel: BridgeChannel;
|
|
191
|
+
}
|
|
192
|
+
interface MessageBulkDeleteEventPayload extends EventEnvelopeBase {
|
|
193
|
+
channelId: Snowflake;
|
|
194
|
+
guildId: Snowflake;
|
|
195
|
+
messageIds: Snowflake[];
|
|
196
|
+
/** Discord `ChannelType` for `channelId` when known. */
|
|
197
|
+
channelType?: number;
|
|
198
|
+
/** Parent category or forum/text parent when the channel reports one. */
|
|
199
|
+
parentChannelId?: Snowflake;
|
|
200
|
+
}
|
|
164
201
|
interface BotEventPayloadMap {
|
|
165
202
|
ready: ReadyEventPayload;
|
|
166
203
|
interactionCreate: InteractionCreateEventPayload;
|
|
167
204
|
messageCreate: MessageCreateEventPayload;
|
|
168
205
|
messageUpdate: MessageUpdateEventPayload;
|
|
169
206
|
messageDelete: MessageDeleteEventPayload;
|
|
207
|
+
messageBulkDelete: MessageBulkDeleteEventPayload;
|
|
170
208
|
messageReactionAdd: MessageReactionAddEventPayload;
|
|
171
209
|
messageReactionRemove: MessageReactionRemoveEventPayload;
|
|
172
210
|
guildCreate: GuildCreateEventPayload;
|
|
@@ -177,6 +215,9 @@ interface BotEventPayloadMap {
|
|
|
177
215
|
threadCreate: ThreadCreateEventPayload;
|
|
178
216
|
threadUpdate: ThreadUpdateEventPayload;
|
|
179
217
|
threadDelete: ThreadDeleteEventPayload;
|
|
218
|
+
channelCreate: ChannelCreateEventPayload;
|
|
219
|
+
channelUpdate: ChannelUpdateEventPayload;
|
|
220
|
+
channelDelete: ChannelDeleteEventPayload;
|
|
180
221
|
}
|
|
181
222
|
type BotEventName = keyof BotEventPayloadMap;
|
|
182
223
|
interface BridgeMessageInput {
|
|
@@ -270,6 +311,53 @@ interface RemoveOwnMessageReactionActionPayload {
|
|
|
270
311
|
messageId: Snowflake;
|
|
271
312
|
emoji: string;
|
|
272
313
|
}
|
|
314
|
+
interface TimeoutMemberActionPayload {
|
|
315
|
+
guildId: Snowflake;
|
|
316
|
+
userId: Snowflake;
|
|
317
|
+
/** Duration in milliseconds (Discord allows up to 28 days). */
|
|
318
|
+
durationMs: number;
|
|
319
|
+
reason?: string;
|
|
320
|
+
}
|
|
321
|
+
interface RemoveMemberTimeoutActionPayload {
|
|
322
|
+
guildId: Snowflake;
|
|
323
|
+
userId: Snowflake;
|
|
324
|
+
reason?: string;
|
|
325
|
+
}
|
|
326
|
+
interface CreateChannelActionPayload {
|
|
327
|
+
guildId: Snowflake;
|
|
328
|
+
name: string;
|
|
329
|
+
/** Discord `ChannelType` (default: `0` guild text). */
|
|
330
|
+
type?: number;
|
|
331
|
+
parentId?: Snowflake;
|
|
332
|
+
topic?: string;
|
|
333
|
+
reason?: string;
|
|
334
|
+
}
|
|
335
|
+
interface EditChannelActionPayload {
|
|
336
|
+
channelId: Snowflake;
|
|
337
|
+
name?: string | null;
|
|
338
|
+
parentId?: Snowflake | null;
|
|
339
|
+
topic?: string | null;
|
|
340
|
+
reason?: string;
|
|
341
|
+
}
|
|
342
|
+
interface DeleteChannelActionPayload {
|
|
343
|
+
channelId: Snowflake;
|
|
344
|
+
reason?: string;
|
|
345
|
+
}
|
|
346
|
+
/** `autoArchiveDuration` is in minutes (Discord-supported values). */
|
|
347
|
+
interface CreateThreadActionPayload {
|
|
348
|
+
parentChannelId: Snowflake;
|
|
349
|
+
name: string;
|
|
350
|
+
/** When set, starts a thread on this message (requires a text-based parent). */
|
|
351
|
+
messageId?: Snowflake;
|
|
352
|
+
type?: 'public' | 'private';
|
|
353
|
+
autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
|
|
354
|
+
reason?: string;
|
|
355
|
+
}
|
|
356
|
+
interface ArchiveThreadActionPayload {
|
|
357
|
+
threadId: Snowflake;
|
|
358
|
+
archived?: boolean;
|
|
359
|
+
reason?: string;
|
|
360
|
+
}
|
|
273
361
|
interface BotActionPayloadMap {
|
|
274
362
|
sendMessage: SendMessageActionPayload;
|
|
275
363
|
editMessage: EditMessageActionPayload;
|
|
@@ -290,6 +378,13 @@ interface BotActionPayloadMap {
|
|
|
290
378
|
removeMemberRole: RemoveMemberRoleActionPayload;
|
|
291
379
|
addMessageReaction: AddMessageReactionActionPayload;
|
|
292
380
|
removeOwnMessageReaction: RemoveOwnMessageReactionActionPayload;
|
|
381
|
+
timeoutMember: TimeoutMemberActionPayload;
|
|
382
|
+
removeMemberTimeout: RemoveMemberTimeoutActionPayload;
|
|
383
|
+
createChannel: CreateChannelActionPayload;
|
|
384
|
+
editChannel: EditChannelActionPayload;
|
|
385
|
+
deleteChannel: DeleteChannelActionPayload;
|
|
386
|
+
createThread: CreateThreadActionPayload;
|
|
387
|
+
archiveThread: ArchiveThreadActionPayload;
|
|
293
388
|
}
|
|
294
389
|
interface DeleteMessageActionResult {
|
|
295
390
|
deleted: true;
|
|
@@ -321,6 +416,10 @@ interface MessageReactionActionResult {
|
|
|
321
416
|
channelId: Snowflake;
|
|
322
417
|
emoji: string;
|
|
323
418
|
}
|
|
419
|
+
interface DeleteChannelActionResult {
|
|
420
|
+
deleted: true;
|
|
421
|
+
channelId: Snowflake;
|
|
422
|
+
}
|
|
324
423
|
interface BotActionResultDataMap {
|
|
325
424
|
sendMessage: BridgeMessage;
|
|
326
425
|
editMessage: BridgeMessage;
|
|
@@ -341,6 +440,13 @@ interface BotActionResultDataMap {
|
|
|
341
440
|
removeMemberRole: BridgeGuildMember;
|
|
342
441
|
addMessageReaction: MessageReactionActionResult;
|
|
343
442
|
removeOwnMessageReaction: MessageReactionActionResult;
|
|
443
|
+
timeoutMember: MemberModerationActionResult;
|
|
444
|
+
removeMemberTimeout: BridgeGuildMember;
|
|
445
|
+
createChannel: BridgeChannel;
|
|
446
|
+
editChannel: BridgeChannel;
|
|
447
|
+
deleteChannel: DeleteChannelActionResult;
|
|
448
|
+
createThread: BridgeThread;
|
|
449
|
+
archiveThread: BridgeThread;
|
|
344
450
|
}
|
|
345
451
|
type BotActionName = keyof BotActionPayloadMap;
|
|
346
452
|
interface BridgeCapabilities {
|
|
@@ -356,6 +462,57 @@ interface EventSubscriptionFilter {
|
|
|
356
462
|
customId?: string | readonly string[];
|
|
357
463
|
/** Matches `BridgeInteraction.kind`. */
|
|
358
464
|
interactionKind?: BridgeInteractionKind | readonly BridgeInteractionKind[];
|
|
465
|
+
/** Matches Discord `ChannelType` when present on the payload (messages, interactions, bulk delete). */
|
|
466
|
+
channelType?: number | readonly number[];
|
|
467
|
+
/** Matches `BridgeMessage.parentChannelId` / thread parent / channel parent when present. */
|
|
468
|
+
parentChannelId?: Snowflake | readonly Snowflake[];
|
|
469
|
+
/** Matches guild thread channels only: same as message `channelId` when `channelType` is a guild thread. */
|
|
470
|
+
threadId?: Snowflake | readonly Snowflake[];
|
|
471
|
+
}
|
|
472
|
+
/** Keys supported on `EventSubscriptionFilter` for `app.on(..., filter)`. */
|
|
473
|
+
type ShardwireSubscriptionFilterKey = keyof EventSubscriptionFilter;
|
|
474
|
+
/** One built-in event and its gateway intent requirements (for `app.catalog()`). */
|
|
475
|
+
interface ShardwireCatalogEvent {
|
|
476
|
+
name: BotEventName;
|
|
477
|
+
requiredIntents: readonly BotIntentName[];
|
|
478
|
+
}
|
|
479
|
+
/** Static discovery surface for built-in events, actions, and subscription filters. */
|
|
480
|
+
interface ShardwireCatalog {
|
|
481
|
+
events: readonly ShardwireCatalogEvent[];
|
|
482
|
+
actions: readonly BotActionName[];
|
|
483
|
+
subscriptionFilters: readonly ShardwireSubscriptionFilterKey[];
|
|
484
|
+
}
|
|
485
|
+
type CapabilityExplanationKind = 'event' | 'action';
|
|
486
|
+
type CapabilityExplanationReasonCode = 'unknown_name' | 'not_negotiated' | 'allowed' | 'denied_by_bridge';
|
|
487
|
+
/** Result of `app.explainCapability(...)`. */
|
|
488
|
+
interface CapabilityExplanation {
|
|
489
|
+
kind: CapabilityExplanationKind;
|
|
490
|
+
name: string;
|
|
491
|
+
/** Whether this name is a built-in Shardwire event or action. */
|
|
492
|
+
known: boolean;
|
|
493
|
+
/** Required gateway intents when `kind` is `event` and `known`. */
|
|
494
|
+
requiredIntents?: readonly BotIntentName[];
|
|
495
|
+
/** After authentication, whether the bridge allows this capability. */
|
|
496
|
+
allowedByBridge?: boolean;
|
|
497
|
+
reasonCode: CapabilityExplanationReasonCode;
|
|
498
|
+
remediation?: string;
|
|
499
|
+
}
|
|
500
|
+
type PreflightIssueSeverity = 'error' | 'warning';
|
|
501
|
+
interface PreflightIssue {
|
|
502
|
+
severity: PreflightIssueSeverity;
|
|
503
|
+
code: string;
|
|
504
|
+
message: string;
|
|
505
|
+
remediation?: string;
|
|
506
|
+
}
|
|
507
|
+
interface PreflightReport {
|
|
508
|
+
ok: boolean;
|
|
509
|
+
connected: boolean;
|
|
510
|
+
capabilities: BridgeCapabilities | null;
|
|
511
|
+
issues: PreflightIssue[];
|
|
512
|
+
}
|
|
513
|
+
interface PreflightDesired {
|
|
514
|
+
events?: readonly BotEventName[];
|
|
515
|
+
actions?: readonly BotActionName[];
|
|
359
516
|
}
|
|
360
517
|
interface EventSubscription<K extends BotEventName = BotEventName> {
|
|
361
518
|
name: K;
|
|
@@ -454,10 +611,19 @@ interface ActionFailure {
|
|
|
454
611
|
error: ActionError;
|
|
455
612
|
}
|
|
456
613
|
type ActionResult<T> = ActionSuccess<T> | ActionFailure;
|
|
614
|
+
/** Structured context on `BridgeCapabilityError` and capability-related action failures. */
|
|
615
|
+
interface BridgeCapabilityErrorDetails {
|
|
616
|
+
reasonCode: 'not_in_capabilities' | 'unknown_event' | 'unknown_action';
|
|
617
|
+
kind?: 'event' | 'action';
|
|
618
|
+
name?: string;
|
|
619
|
+
remediation: string;
|
|
620
|
+
requiredIntents?: readonly BotIntentName[];
|
|
621
|
+
}
|
|
457
622
|
declare class BridgeCapabilityError extends Error {
|
|
458
623
|
readonly kind: 'event' | 'action';
|
|
459
624
|
readonly name: string;
|
|
460
|
-
|
|
625
|
+
readonly details?: BridgeCapabilityErrorDetails | undefined;
|
|
626
|
+
constructor(kind: 'event' | 'action', name: string, message?: string, details?: BridgeCapabilityErrorDetails | undefined);
|
|
461
627
|
}
|
|
462
628
|
type EventHandler<K extends BotEventName> = (payload: BotEventPayloadMap[K]) => void;
|
|
463
629
|
type AppBridgeActionInvokeOptions = {
|
|
@@ -484,6 +650,27 @@ interface AppBridge {
|
|
|
484
650
|
connected(): boolean;
|
|
485
651
|
connectionId(): string | null;
|
|
486
652
|
capabilities(): BridgeCapabilities;
|
|
653
|
+
/**
|
|
654
|
+
* Static discovery: built-in events (with intent hints), actions, and subscription filter keys.
|
|
655
|
+
* Does not require a connection.
|
|
656
|
+
*/
|
|
657
|
+
catalog(): ShardwireCatalog;
|
|
658
|
+
/**
|
|
659
|
+
* Explain whether an event or action is built-in and whether the current connection allows it.
|
|
660
|
+
* Call after `await app.ready()` for `allowedByBridge` / `reasonCode` beyond `not_negotiated`.
|
|
661
|
+
*/
|
|
662
|
+
explainCapability(query: {
|
|
663
|
+
kind: 'event';
|
|
664
|
+
name: BotEventName;
|
|
665
|
+
} | {
|
|
666
|
+
kind: 'action';
|
|
667
|
+
name: BotActionName;
|
|
668
|
+
}): CapabilityExplanation;
|
|
669
|
+
/**
|
|
670
|
+
* Run startup diagnostics after authenticating. Does not throw on subscription/capability mismatches;
|
|
671
|
+
* use `report.ok` and `report.issues`. Call before `app.on(...)` to validate `desired` against negotiated caps.
|
|
672
|
+
*/
|
|
673
|
+
preflight(desired?: PreflightDesired): Promise<PreflightReport>;
|
|
487
674
|
on<K extends BotEventName>(name: K, handler: EventHandler<K>, filter?: EventSubscriptionFilter): Unsubscribe;
|
|
488
675
|
off<K extends BotEventName>(name: K, handler: EventHandler<K>): void;
|
|
489
676
|
}
|
|
@@ -492,4 +679,35 @@ declare function createBotBridge(options: BotBridgeOptions): BotBridge;
|
|
|
492
679
|
|
|
493
680
|
declare function connectBotBridge(options: AppBridgeOptions): AppBridge;
|
|
494
681
|
|
|
495
|
-
|
|
682
|
+
/** Returns the full static Shardwire catalog (not negotiated per-connection). */
|
|
683
|
+
declare function getShardwireCatalog(): ShardwireCatalog;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Defer a slash/menu interaction, then edit the deferred reply.
|
|
687
|
+
* Useful for long-running handlers that must acknowledge within Discord's window.
|
|
688
|
+
*/
|
|
689
|
+
declare function deferThenEditInteractionReply(app: Pick<AppBridge, 'actions'>, args: {
|
|
690
|
+
interactionId: DeferInteractionActionPayload['interactionId'];
|
|
691
|
+
defer?: Pick<DeferInteractionActionPayload, 'ephemeral'>;
|
|
692
|
+
edit: EditInteractionReplyActionPayload;
|
|
693
|
+
}, options?: AppBridgeActionInvokeOptions): Promise<ActionResult<BotActionResultDataMap['editInteractionReply']>>;
|
|
694
|
+
/**
|
|
695
|
+
* Defer a component interaction with type `DEFER_UPDATE_MESSAGE`, then edit the reply.
|
|
696
|
+
*/
|
|
697
|
+
declare function deferUpdateThenEditInteractionReply(app: Pick<AppBridge, 'actions'>, args: {
|
|
698
|
+
interactionId: DeferUpdateInteractionActionPayload['interactionId'];
|
|
699
|
+
edit: EditInteractionReplyActionPayload;
|
|
700
|
+
}, options?: AppBridgeActionInvokeOptions): Promise<ActionResult<BotActionResultDataMap['editInteractionReply']>>;
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Create a thread from a parent channel (optionally on a message), then send a message in that thread.
|
|
704
|
+
*/
|
|
705
|
+
declare function createThreadThenSendMessage(app: Pick<AppBridge, 'actions'>, args: {
|
|
706
|
+
thread: CreateThreadActionPayload;
|
|
707
|
+
message: Omit<SendMessageActionPayload, 'channelId'>;
|
|
708
|
+
}, options?: AppBridgeActionInvokeOptions): Promise<{
|
|
709
|
+
threadResult: ActionResult<BotActionResultDataMap['createThread']>;
|
|
710
|
+
messageResult: ActionResult<BotActionResultDataMap['sendMessage']>;
|
|
711
|
+
}>;
|
|
712
|
+
|
|
713
|
+
export { type ActionError, type ActionErrorDetails, type ActionFailure, type ActionResult, type ActionSuccess, type AddMemberRoleActionPayload, type AddMessageReactionActionPayload, type AppBridge, type AppBridgeActionInvokeOptions, type AppBridgeActions, type AppBridgeMetricsHooks, type AppBridgeOptions, type ArchiveThreadActionPayload, type BanMemberActionPayload, type BotActionName, type BotActionPayloadMap, type BotActionResultDataMap, type BotBridge, type BotBridgeOptions, type BotBridgeSecret, type BotEventName, type BotEventPayloadMap, type BotIntentName, type BridgeAttachment, type BridgeCapabilities, BridgeCapabilityError, type BridgeCapabilityErrorDetails, type BridgeChannel, type BridgeDeletedMessage, type BridgeGuild, type BridgeGuildMember, type BridgeInteraction, type BridgeInteractionKind, type BridgeMessage, type BridgeMessageInput, type BridgeMessageReaction, type BridgeMessageReference, type BridgeReactionEmoji, type BridgeThread, type BridgeUser, type CapabilityExplanation, type CapabilityExplanationKind, type CapabilityExplanationReasonCode, type ChannelCreateEventPayload, type ChannelDeleteEventPayload, type ChannelUpdateEventPayload, type CreateChannelActionPayload, type CreateThreadActionPayload, type DeferInteractionActionPayload, type DeferInteractionActionResult, type DeferUpdateInteractionActionPayload, type DeferUpdateInteractionActionResult, type DeleteChannelActionPayload, type DeleteChannelActionResult, type DeleteInteractionReplyActionPayload, type DeleteInteractionReplyActionResult, type DeleteMessageActionPayload, type DeleteMessageActionResult, type EditChannelActionPayload, type EditInteractionReplyActionPayload, type EditMessageActionPayload, type EventEnvelopeBase, type EventHandler, type EventSubscription, type EventSubscriptionFilter, type FetchMemberActionPayload, type FetchMessageActionPayload, type FollowUpInteractionActionPayload, type GuildCreateEventPayload, type GuildDeleteEventPayload, type GuildMemberAddEventPayload, type GuildMemberRemoveEventPayload, type GuildMemberUpdateEventPayload, type InteractionCreateEventPayload, type KickMemberActionPayload, type MemberModerationActionResult, type MessageBulkDeleteEventPayload, type MessageCreateEventPayload, type MessageDeleteEventPayload, type MessageReactionActionResult, type MessageReactionAddEventPayload, type MessageReactionRemoveEventPayload, type MessageUpdateEventPayload, type PreflightDesired, type PreflightIssue, type PreflightIssueSeverity, type PreflightReport, type ReadyEventPayload, type RemoveMemberRoleActionPayload, type RemoveMemberTimeoutActionPayload, type RemoveOwnMessageReactionActionPayload, type ReplyToInteractionActionPayload, type ScopedSecretConfig, type SecretPermissions, type SendMessageActionPayload, type ShardwireCatalog, type ShardwireCatalogEvent, type ShardwireLogger, type ShardwireSubscriptionFilterKey, type ShowModalActionPayload, type ShowModalActionResult, type ThreadCreateEventPayload, type ThreadDeleteEventPayload, type ThreadUpdateEventPayload, type TimeoutMemberActionPayload, type Unsubscribe, type UpdateInteractionActionPayload, connectBotBridge, createBotBridge, createThreadThenSendMessage, deferThenEditInteractionReply, deferUpdateThenEditInteractionReply, getShardwireCatalog };
|