@theholocron/holocron-plugin-discord 5.0.0-alpha.39 → 5.0.0-alpha.390

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 CHANGED
@@ -1,3 +1,5 @@
1
+ <!-- alex disable host-hostess -->
2
+
1
3
  <!-- editorconfig-checker-disable-file -->
2
4
 
3
5
  # `@theholocron/holocron-plugin-discord`
@@ -61,3 +63,29 @@ server membership is required — generate one in Discord under
61
63
  The webhook id and token are embedded in the URL path — no `Authorization`
62
64
  header is sent. `parseWebhookUrl` is exported as a utility for callers
63
65
  that need to split the URL into its parts.
66
+
67
+ ## Provisioning
68
+
69
+ `holocron notifications setup` and `holocron notifications channel add` create
70
+ channels, roles and webhooks through the `notifications` capability's `ensure*`
71
+ methods. They use the **Holonet bot**, not a webhook URL:
72
+
73
+ - `HOLOCRON_DISCORD_BOT_TOKEN` (or `DISCORD_BOT_TOKEN`), or the keyring entry
74
+ `discord.holonet` (`holocron auth set discord.holonet <token>`) — the bot token
75
+ from the Developer Portal. Only read when a provisioning command runs, or when
76
+ `holocron doctor` checks a provider that has a `guildId`; posting never needs it.
77
+ - `HOLOCRON_DISCORD_CLIENT_SECRET` (or `DISCORD_CLIENT_SECRET`), or the keyring entry
78
+ `discord.holonet.oauth` — the application's OAuth client secret (Developer Portal →
79
+ OAuth2 → Reset Secret). Only `holocron notifications link` reads it, to learn which
80
+ GitHub account a member owns; the API can neither create nor read it.
81
+ - `guildId` — the server id (not a secret), set in the provider options.
82
+ - `layout` — categories, channels (each optionally with a `webhook`) and roles.
83
+
84
+ The bot needs Manage Channels, Manage Roles, Manage Webhooks and View Channels.
85
+ Everything is idempotent (looked up by name). Discord returns a webhook's URL
86
+ only to the application that created it, so a webhook the bot did not create
87
+ cannot have its URL read back.
88
+
89
+ `baseUrl` only redirects posting. The bot token is always sent to the real
90
+ Discord API unless `unsafeBotBaseUrl: true` is also set (meant for tests that
91
+ stub the API), so a changed config cannot redirect the token to another host.
package/dist/index.d.mts CHANGED
@@ -1,32 +1,19 @@
1
- import { AuthError, Notifications, ResolveTokenInput } from "@theholocron/cli";
2
- //#region src/auth.d.ts
3
- declare const resolveToken: (input?: ResolveTokenInput) => string;
4
- //#endregion
5
- //#region src/rest.d.ts
6
- interface DiscordClientOptions {
7
- /** Override base URL for tests. Default: https://discord.com/api/v10 */
8
- baseUrl?: string;
9
- fetch?: typeof fetch;
10
- }
11
- interface DiscordWebhookInfo {
12
- id: string;
13
- name: string;
14
- guild_id?: string;
15
- }
16
- interface DiscordClient {
17
- webhooks: {
18
- get(id: string, token: string): Promise<DiscordWebhookInfo>;
19
- execute(id: string, token: string, content: string): Promise<void>;
20
- };
21
- }
22
- declare function createDiscordClient({ baseUrl, fetch: fetchImpl }?: DiscordClientOptions): DiscordClient;
23
- /** Parse a Discord webhook URL into its id and token parts. */
24
- declare function parseWebhookUrl(url: string): {
25
- id: string;
26
- token: string;
27
- };
28
- //#endregion
29
- //#region src/capabilities/notifications.d.ts
1
+ import { AuthError, DiscussionPatch, DiscussionPost, EnsureDiscussionInput, EnsureWebhookResult, EnsuredDiscussion, EnsuredResource, Notifications, NotificationsAccess, NotificationsApplicationLayout, NotificationsDelivery, NotificationsEveryoneLayout, NotificationsForumTag, NotificationsLayout, NotificationsMember, NotificationsOnboardingLayout, NotificationsPinnedLayout, NotificationsServerLayout, NotificationsSignIn, NotificationsWelcomeLayout, PluginToken, ResolveTokenInput, ServerInspection, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
2
+ import { DiscordBotClient, DiscordClient, DiscordClientOptions, DiscordOAuthClient, DiscordWebhookInfo, createDiscordClient, parseWebhookUrl } from "@theholocron/discord-client";
3
+ /** Resolves the Discord webhook URL from `--token`, `HOLOCRON_DISCORD_WEBHOOK`, `DISCORD_WEBHOOK_URL` or the keyring, and throws an `AuthError` when none is set. */
4
+ export declare const resolveToken: import("@theholocron/cli").TokenResolver;
5
+ /** Resolves the Discord bot token used to provision channels, roles and webhooks, from `HOLOCRON_DISCORD_BOT_TOKEN`, `DISCORD_BOT_TOKEN` or the keyring. */
6
+ export declare const resolveBotToken: import("@theholocron/cli").TokenResolver;
7
+ /** Resolves the Discord application's OAuth client secret used to sign members in, from `HOLOCRON_DISCORD_CLIENT_SECRET`, `DISCORD_CLIENT_SECRET` or the keyring. */
8
+ export declare const resolveClientSecret: import("@theholocron/cli").TokenResolver;
9
+ /**
10
+ * Every token this plugin takes, for `holocron doctor tokens`. `verifyToken` checks a webhook URL, so the bot token has
11
+ * its own `verify` (it asks for the bot's application) and the OAuth client secret, which cannot be checked without a
12
+ * sign-in, is listed but not handed to it. The webhook is the last resort for a post that names no
13
+ * channel, alias or `defaultChannel`, so nothing needs it by default (`optional`).
14
+ */
15
+ export declare const tokens: PluginToken[];
16
+ /** Options for the Discord `notifications` capability: webhook aliases, the default channel, and the server it provisions. */
30
17
  interface DiscordNotificationsOptions {
31
18
  /**
32
19
  * Named aliases mapping a logical channel name to its webhook URL.
@@ -38,60 +25,371 @@ interface DiscordNotificationsOptions {
38
25
  * without an explicit channel, or with an empty string.
39
26
  */
40
27
  defaultChannel?: string;
28
+ /** Discord server (guild) id that `notifications setup` provisions. Not a secret. */
29
+ guildId?: string;
30
+ /** The server layout `notifications setup` applies. */
31
+ layout?: NotificationsLayout;
32
+ /** A custom API host, for tests. Webhook tokens are only sent to it when `unsafeBotBaseUrl` is also set. */
33
+ baseUrl?: string;
34
+ /** Also send the bot token to `baseUrl`. Off by default so a changed config cannot redirect the bot token to another host; tests that stub the API set it. */
35
+ unsafeBotBaseUrl?: boolean;
41
36
  }
42
- declare class DiscordNotifications implements Notifications {
37
+ /** The Discord implementation of the `notifications` capability: sends messages through webhooks and provisions the server's channels, roles and webhooks with the bot. */
38
+ export declare class DiscordNotifications implements Notifications {
43
39
  private readonly client;
44
40
  private readonly opts;
45
41
  /** Memoized thunk — resolves the default webhook URL on the first `send()`. */
46
42
  private readonly defaultWebhookUrl;
43
+ /** Memoized thunk — resolves the bot token on first provisioning call, never on `send()`. */
44
+ private readonly bot;
45
+ /** Builds the OAuth client for one redirect URI; needs the application's client secret. */
46
+ private readonly oauth;
47
+ /** The capability this class provides, always `"notifications"`. */
47
48
  readonly key: "notifications";
49
+ /** The provider name, `"discord"`. */
48
50
  readonly providerName = "discord";
49
51
  constructor(client: DiscordClient, opts: DiscordNotificationsOptions,
50
52
  /** Memoized thunk — resolves the default webhook URL on the first `send()`. */
51
- defaultWebhookUrl: () => string);
53
+ defaultWebhookUrl: () => string,
54
+ /** Memoized thunk — resolves the bot token on first provisioning call, never on `send()`. */
55
+ bot?: () => DiscordBotClient,
56
+ /** Builds the OAuth client for one redirect URI; needs the application's client secret. */
57
+ oauth?: (redirectUri: string) => Promise<DiscordOAuthClient>);
58
+ /**
59
+ * Sign a member in with Discord to learn which GitHub account they own. Asks only for `identify` and
60
+ * `connections`, reads the account Discord has verified, and revokes the token before returning: nothing
61
+ * about the sign-in is kept.
62
+ */
63
+ signIn(): NotificationsSignIn;
64
+ get layout(): NotificationsLayout | undefined;
52
65
  send(channel: string, message: string): Promise<void>;
66
+ /**
67
+ * `holocron doctor`: the bot token is valid and can see the configured server.
68
+ * Null when no `guildId` is set -- a post-only config has no bot to check. A
69
+ * `layout` without a `guildId` is a half-written provisioning config, so that
70
+ * fails instead of passing as post-only.
71
+ */
72
+ whoami(): Promise<{
73
+ target: string;
74
+ } | null>;
75
+ /**
76
+ * Read-only: what is on the server, for the parts of `layout` we will compare. Webhooks are
77
+ * listed only for channels the layout gives one (one request each), so the cost scales with
78
+ * the layout, not with the server.
79
+ */
80
+ inspect(layout: NotificationsLayout): Promise<ServerInspection>;
81
+ /**
82
+ * What the bot keeps: the usual set, Pin Messages when the layout pins messages, and Manage Threads when it
83
+ * declares a forum (a post's tags are applied by the bot, and a moderated tag only by someone who can manage threads),
84
+ * and Add Reactions when a forum has `starterReactions` (without it the bot skips them and the post still gets made).
85
+ */
86
+ private needs;
87
+ /** Where to re-invite the bot so its role holds what `setup` needs. Re-authorising updates the role in place. */
88
+ private inviteUrl;
89
+ /** Changing server settings needs Manage Server; an empty edit proves the bot has it without changing anything. */
90
+ preflight(layout: NotificationsLayout): Promise<void>;
91
+ /** The one role with this name, or an error saying why not: two would mean granting something to the wrong members. */
92
+ private static pickRole;
93
+ /**
94
+ * The one text or announcement channel with this name, or an error saying why not. A forum counts only for a
95
+ * setting that can point at one (`forums`): the welcome screen and onboarding can; a pinned message and the server's
96
+ * own channels cannot.
97
+ */
98
+ private static pickChannelId;
99
+ /** True for a 403 that is about permissions, not about the bot being unable to see the server at all. */
100
+ private static missingPermissions;
101
+ /** An invite link, or nothing when building it needs a request that fails: the advice must not depend on one. */
102
+ private inviteOrNothing;
103
+ /**
104
+ * Changing a role's permissions is refused (403) when the role would gain one the bot does not hold itself: Discord
105
+ * lets a bot give only what it has. The bot's own role is managed by its integration, so it cannot be edited by
106
+ * hand; re-authorising the bot with the permissions setup needs updates it in place.
107
+ */
108
+ private rolePermissionsHint;
109
+ /** Turning community on or off needs Administrator, which is more than the bot should keep. */
110
+ private communityHint;
111
+ /** A 403 on a server edit becomes the explanation and the invite link; anything else is passed on as it is. */
112
+ private manageServerHint;
113
+ ensureServer(settings: NotificationsServerLayout): Promise<{
114
+ updated: string[];
115
+ }>;
116
+ /** What the bot's roles give it server-wide (the owner holds every permission), before any channel overwrite. */
117
+ private serverPermissions;
118
+ /**
119
+ * The permissions `needs()` lists that the bot's roles do not give it server-wide, in plain words ("Manage Threads"),
120
+ * with the invite link that asks for them again when some are missing. The owner and an Administrator hold every
121
+ * permission. Channel overwrites are not looked at: the forum's own check does that.
122
+ */
123
+ private missingBotPermissions;
124
+ holdsPermission(permission: string): Promise<boolean>;
125
+ /**
126
+ * What a member holding `bits` through the roles in `held` has in a channel, in the order Discord applies the
127
+ * channel's overwrites: @everyone, then the roles, then the member itself.
128
+ */
129
+ private static afterOverwrites;
130
+ /**
131
+ * What the bot can do with the threads of a forum: start posts and reply (`post`) and tag and close them (`manage`).
132
+ * The owner and an Administrator hold every permission, whatever the forum's overwrites say.
133
+ */
134
+ private botThreadsIn;
135
+ /**
136
+ * Whether a channel's own overwrites take a permission away from a bot whose roles grant it, in the order Discord
137
+ * applies them: @everyone, then the bot's roles, then the bot itself. Read fresh, since a person may have just edited them.
138
+ */
139
+ private channelDenies;
140
+ /** The messages this bot posted in a channel, pinned or not, among the channel's last hundred. */
141
+ private ownMessages;
142
+ /**
143
+ * The layout's text with each `#name` that is one of the server's channels turned into Discord's own link to it
144
+ * (`<#id>`), so the message shows clickable channels. A name that matches no channel, or more than one, is left as written.
145
+ */
146
+ private static linkChannels;
147
+ /**
148
+ * The text of a pinned message. The CLI reads a message's `file` into `content` before it calls the provider, so
149
+ * the text is only missing when a caller skipped that.
150
+ */
151
+ private static pinText;
152
+ /** The layout's messages grouped by channel, in the order the channels first appear, with channel names linked. */
153
+ private static pinsByChannel;
154
+ /**
155
+ * What differs in one channel: the declared messages that are not pinned yet, and the bot's pinned messages the
156
+ * layout does not declare (or declares once and the bot pinned twice). The layout is the whole set of the bot's
157
+ * pins in a channel it names.
158
+ */
159
+ private static pinDrift;
160
+ /** Whether each pinned message is in place: pinned by this bot with exactly the layout's text, and nothing else of the bot's pinned beside it. */
161
+ private pinnedStates;
162
+ private discussionStore?;
163
+ /** The discussion posts of this instance's forum channels, which read each forum once. */
164
+ private discussions;
165
+ /** Finds the post for a document in a forum channel, or makes it. See {@link DiscordDiscussions}. */
166
+ ensureDiscussion(input: EnsureDiscussionInput): Promise<EnsuredDiscussion>;
167
+ /** The post for a document in a forum channel, or `undefined`. */
168
+ readDiscussion(channel: string, key: string, url?: string): Promise<DiscussionPost | undefined>;
169
+ /** Changes a document's post: its title, its tag, the state last synced, the pull request line. */
170
+ updateDiscussion(channel: string, key: string, patch: DiscussionPatch): Promise<void>;
171
+ /** Appends a message to a document's post, reopening and closing it again if it was closed. */
172
+ postDiscussionMessage(channel: string, key: string, content: string, opts?: {
173
+ quiet?: boolean;
174
+ }): Promise<void>;
175
+ /** The text of a post's recent messages, newest first. */
176
+ readDiscussionMessages(channel: string, key: string, limit?: number): Promise<string[]>;
177
+ /** Keeps the oldest post for `key` and deletes the others; returns how many it deleted. */
178
+ dedupeDiscussion(channel: string, key: string): Promise<number>;
179
+ /**
180
+ * Posts `content` (up to 2000 characters) in a text channel as the bot, without letting it mention anyone. A `#name`
181
+ * that is one of the server's channels is linked.
182
+ */
183
+ postMessage(channel: string, content: string): Promise<void>;
184
+ ensurePinned(pinned: NotificationsPinnedLayout[]): Promise<{
185
+ updated: string[];
186
+ }>;
187
+ /** A 403 on pinning becomes the missing permission and a link that grants it, which `setup` can walk a person through. */
188
+ private pinHint;
189
+ /** A 403 on the welcome screen or onboarding becomes the likely reason; anything else is passed on. */
190
+ private static communityFeatureHint;
191
+ /** The numeric code Discord puts in the JSON body of an error, or undefined when the body is not that. */
192
+ private static codeOf;
193
+ /** The welcome screen; a server that never had one answers 404 (10069), which is an empty screen. */
194
+ private welcomeScreenOf;
195
+ ensureWelcome(welcome: NotificationsWelcomeLayout): Promise<{
196
+ updated: string[];
197
+ }>;
198
+ /** An onboarding prompt reduced to what the layout can state, so the server's and the layout's can be compared. */
199
+ private static onboardingKey;
200
+ ensureOnboarding(onboarding: NotificationsOnboardingLayout): Promise<{
201
+ updated: string[];
202
+ }>;
203
+ ensureEveryone(everyone: NotificationsEveryoneLayout): Promise<{
204
+ updated: string[];
205
+ }>;
206
+ ensureApplication(app: NotificationsApplicationLayout): Promise<{
207
+ updated: string[];
208
+ todo?: string[];
209
+ }>;
210
+ /** Whether the Server Members Intent is on: the unverified app's toggle, or the verified app's own bit. */
211
+ private static membersIntentOn;
212
+ validateLayout(layout: NotificationsLayout): string | undefined;
213
+ private botUser?;
214
+ private botId;
215
+ /**
216
+ * The overwrites that make a channel look like `access`. The list is exact: it replaces
217
+ * whatever was set by hand. `[]` (public) when nothing is restricted.
218
+ */
219
+ private overwritesFor;
220
+ /**
221
+ * Read an access back out of a channel's overwrites, naming roles as the layout does. Only
222
+ * overwrites of the shape {@link overwritesFor} writes can be read back; anything else
223
+ * (a role-specific deny, a member overwrite, only some of the posting bits) means the
224
+ * channel's real access is not something the layout can state, and is reported as `"custom"`
225
+ * rather than guessed at.
226
+ */
227
+ private accessOf;
228
+ /** The server's roles, fetched once and forgotten whenever setup changes a role. */
229
+ private roleLoad?;
230
+ private roleList;
231
+ /** The server this run created, which takes over from `guildId` for the rest of the run. */
232
+ private createdGuild?;
233
+ private guild;
234
+ /**
235
+ * The server's channel list, fetched once per instance. Every ensure* call used
236
+ * to refetch it -- about 40 identical GETs in one setup run -- and Discord
237
+ * rate-limited the route. Our own creates and edits update the copy, so it
238
+ * stays accurate for the run; a new run builds a new instance.
239
+ *
240
+ * It is the in-flight promise that is shared, not the array: callers that start
241
+ * while the first fetch is pending all get the same snapshot, so a later
242
+ * response can never overwrite what an earlier caller added.
243
+ */
244
+ private channelLoad?;
245
+ private channelList;
246
+ /**
247
+ * Create a channel and add it to the shared list. If the create fails, Discord
248
+ * may still have applied it (a timeout looks the same as a refusal), so forget the
249
+ * list: the next ensure refetches the server's real state instead of creating a
250
+ * duplicate.
251
+ */
252
+ private createChannel;
253
+ private static same;
254
+ ensureCategory(name: string, opts?: {
255
+ access?: NotificationsAccess;
256
+ }): Promise<EnsuredResource>;
257
+ /**
258
+ * Edit a channel and keep the shared list in step; forget the list if the edit may have half-applied.
259
+ * Discord answers with the channel as it now is: if the overwrites that come back are not the ones we
260
+ * sent, something else changed it at the same time, so say so instead of reporting success.
261
+ */
262
+ private modifyChannel;
263
+ /**
264
+ * Find a channel by name. A name can exist in several categories, so with a
265
+ * parent: prefer the one already there, then an uncategorised one (moved in);
266
+ * never grab a channel that lives under a different category. Announcement
267
+ * channels count: reusing one beats creating a same-named text channel.
268
+ */
269
+ private static findChannel;
270
+ /** A forum tag in the layout's terms. */
271
+ private static tagOf;
272
+ /** A layout tag as Discord takes it. */
273
+ private static tagInput;
274
+ /**
275
+ * The forum's tags once the layout's are in: every tag it has already (kept, with the emoji and `moderated` the layout
276
+ * gives it) and each layout tag it lacks, added. A tag the layout does not list is never removed, since a post
277
+ * carries it. Returns `undefined` when nothing differs.
278
+ */
279
+ private static mergeTags;
280
+ /**
281
+ * Finds the text or announcement channel with this name (under the category, when given), or creates it; reports
282
+ * whether it was created. With `kind: "forum"` it is a forum channel with the layout's tags. Discord cannot turn one
283
+ * kind into the other and this never deletes, so a channel of the other kind with the name stops the run with the fix.
284
+ */
285
+ ensureChannel(input: {
286
+ name: string;
287
+ category?: string;
288
+ topic?: string;
289
+ access?: NotificationsAccess;
290
+ kind?: "text" | "forum";
291
+ tags?: NotificationsForumTag[];
292
+ defaultReaction?: string;
293
+ }): Promise<EnsuredResource>;
294
+ /** Finds the webhook with this name on the channel, or creates it; the optional avatar is the picture it posts with. */
295
+ ensureWebhook(input: {
296
+ channel: string;
297
+ name: string;
298
+ category?: string;
299
+ avatar?: string;
300
+ }): Promise<EnsureWebhookResult>;
301
+ checkDelivery(input: {
302
+ channel: string;
303
+ name: string;
304
+ category?: string;
305
+ text: string;
306
+ keep?: boolean;
307
+ }): Promise<NotificationsDelivery>;
308
+ createServer(input: {
309
+ name: string;
310
+ force?: boolean;
311
+ }): Promise<{
312
+ id: string;
313
+ name: string;
314
+ }>;
315
+ /** A server this bot owns (not one it only belongs to) with exactly this name, read across every page. */
316
+ private botOwnedServer;
317
+ inviteLink(channelName: string): Promise<string>;
318
+ hasMember(memberId: string): Promise<boolean>;
319
+ transferServer(memberId: string): Promise<void>;
320
+ serverOwner(): Promise<{
321
+ id: string;
322
+ isBot: boolean;
323
+ name?: string;
324
+ }>;
325
+ /** The one role with this name, or an error that says what to fix: none, or more than one. */
326
+ private roleNamed;
327
+ roleMembers(roleName: string): Promise<NotificationsMember[]>;
328
+ addRoleMember(roleName: string, memberId: string): Promise<void>;
329
+ removeRoleMember(roleName: string, memberId: string): Promise<void>;
330
+ /** Finds the role with this name, or creates it with the given mentionable, color, hoist and permissions settings; reports whether it was created. */
331
+ ensureRole(input: {
332
+ name: string;
333
+ mentionable?: boolean;
334
+ color?: string;
335
+ hoist?: boolean;
336
+ permissions?: string[];
337
+ }): Promise<EnsuredResource>;
53
338
  private resolve;
54
339
  }
55
- //#endregion
56
- //#region src/verify-token.d.ts
57
- interface VerifyTokenSuccess {
58
- ok: true;
59
- subject: string;
60
- }
61
- interface VerifyTokenFailure {
62
- ok: false;
63
- message: string;
64
- }
65
- type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
66
340
  interface VerifyTokenOptions {
67
341
  baseUrl?: string;
68
342
  fetch?: typeof fetch;
69
343
  }
70
- declare function verifyToken(webhookUrl: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
71
- //#endregion
72
- //#region src/index.d.ts
73
- interface DiscordPluginOptions extends ResolveTokenInput, DiscordNotificationsOptions {
344
+ /** Checks a Discord webhook URL by fetching the webhook; resolves to its name and id, or the failure message. */
345
+ export declare function verifyToken(webhookUrl: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
346
+ /** Options for the Discord plugin: how the webhook URL is resolved plus the notifications settings. */
347
+ export interface DiscordPluginOptions extends ResolveTokenInput, DiscordNotificationsOptions {
74
348
  /** Override base URL for tests. Default: https://discord.com/api/v10 */
75
349
  baseUrl?: string;
350
+ /** The `fetch` to use instead of the global one, for tests. */
76
351
  fetch?: typeof fetch;
352
+ /**
353
+ * Also send the BOT token to `baseUrl`. Off by default: `baseUrl` comes from a
354
+ * repo's config, and a changed config must not be able to redirect the bot
355
+ * token to another host. Tests that stub the API set it.
356
+ */
357
+ unsafeBotBaseUrl?: boolean;
77
358
  }
78
- interface PluginContext {
359
+ /** The shared state the Discord plugin's capability and probes are built from. */
360
+ export interface PluginContext {
361
+ /** The options the plugin was created with. */
79
362
  options: DiscordPluginOptions;
363
+ /** The webhook client used to send messages. */
80
364
  client: DiscordClient;
81
365
  /**
82
366
  * Memoized — the resolved "token" IS Discord's default webhook URL, and it is
83
367
  * resolved on first `send()`, not at plugin load. `describe()` never calls it.
84
368
  */
85
369
  defaultWebhookUrl: () => string;
370
+ /** Memoized — resolves the bot token on the first provisioning call, or when `holocron doctor` checks a provider that has a `guildId`; `send()` and `describe()` never touch it. */
371
+ bot: () => DiscordBotClient;
372
+ /** Builds the OAuth client for one redirect URI; resolves the application id and the client secret on first use. */
373
+ oauth: (redirectUri: string) => Promise<DiscordOAuthClient>;
86
374
  }
87
- declare function createContext(options?: DiscordPluginOptions): PluginContext;
88
- declare function notifications(ctx: PluginContext): Notifications;
89
- declare function createPlugin(options?: DiscordPluginOptions): {
375
+ /** Builds the plugin context from its options; the webhook URL, bot token and client secret are each resolved on first use. */
376
+ export declare function createContext(options?: DiscordPluginOptions): PluginContext;
377
+ /** Builds the `notifications` capability for a context. */
378
+ export declare function notifications(ctx: PluginContext): Notifications;
379
+ /**
380
+ * Creates the Discord plugin: its `notifications` capability and its `connection` probe. The probe checks the webhook
381
+ * when there is one, and the bot token when there is not: the webhook is only a last resort for a post that names no
382
+ * channel, so a missing one is not a failed connection when the bot can be reached.
383
+ */
384
+ export declare function createPlugin(options?: DiscordPluginOptions): {
90
385
  name: string;
386
+ probes: {
387
+ connection: import("@theholocron/cli").Probe;
388
+ };
91
389
  capabilities: {
92
390
  notifications: () => Notifications;
93
391
  };
94
392
  };
95
- declare const AUTH_HINT: string;
96
- //#endregion
97
- export { AUTH_HINT, AuthError, type DiscordClient, type DiscordClientOptions, DiscordNotifications, type DiscordNotificationsOptions, DiscordPluginOptions, type DiscordWebhookInfo, PluginContext, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createDiscordClient, createPlugin, notifications, parseWebhookUrl, resolveToken, verifyToken };
393
+ /** One-line hint printed by `holocron auth set discord` when no webhook URL is supplied or the supplied one is rejected. */
394
+ export declare const AUTH_HINT: string;
395
+ export { AuthError, type DiscordClient, type DiscordClientOptions, type DiscordNotificationsOptions, type DiscordWebhookInfo, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createDiscordClient, parseWebhookUrl };