@theholocron/holocron-plugin-discord 5.0.0-alpha.182 → 5.0.0-alpha.184

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
@@ -68,8 +68,10 @@ that need to split the URL into its parts.
68
68
  channels, roles and webhooks through the `notifications` capability's `ensure*`
69
69
  methods. They use the **Holonet bot**, not a webhook URL:
70
70
 
71
- - `HOLOCRON_DISCORD_BOT_TOKEN` (or `DISCORD_BOT_TOKEN`) — the bot token from
72
- the Developer Portal. Only read when a provisioning command runs.
71
+ - `HOLOCRON_DISCORD_BOT_TOKEN` (or `DISCORD_BOT_TOKEN`), or the keyring entry
72
+ `discord.holonet` (`holocron auth set discord.holonet <token>`) — the bot token
73
+ from the Developer Portal. Only read when a provisioning command runs, or when
74
+ `holocron doctor` checks a provider that has a `guildId`; posting never needs it.
73
75
  - `guildId` — the server id (not a secret), set in the provider options.
74
76
  - `layout` — categories, channels (each optionally with a `webhook`) and roles.
75
77
 
package/dist/index.d.mts CHANGED
@@ -37,6 +37,15 @@ declare class DiscordNotifications implements Notifications {
37
37
  bot?: () => DiscordBotClient);
38
38
  get layout(): NotificationsLayout | undefined;
39
39
  send(channel: string, message: string): Promise<void>;
40
+ /**
41
+ * `holocron doctor`: the bot token is valid and can see the configured server.
42
+ * Null when no `guildId` is set -- a post-only config has no bot to check. A
43
+ * `layout` without a `guildId` is a half-written provisioning config, so that
44
+ * fails instead of passing as post-only.
45
+ */
46
+ whoami(): Promise<{
47
+ target: string;
48
+ } | null>;
40
49
  private guild;
41
50
  private static same;
42
51
  ensureCategory(name: string): Promise<EnsuredResource>;
@@ -91,7 +100,7 @@ interface PluginContext {
91
100
  * resolved on first `send()`, not at plugin load. `describe()` never calls it.
92
101
  */
93
102
  defaultWebhookUrl: () => string;
94
- /** Memoized — resolves the bot token on the first provisioning call; `send()` and `describe()` never touch it. */
103
+ /** 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. */
95
104
  bot: () => DiscordBotClient;
96
105
  }
97
106
  declare function createContext(options?: DiscordPluginOptions): PluginContext;
package/dist/index.mjs CHANGED
@@ -11,8 +11,8 @@ const resolveToken = createResolveToken({
11
11
  const resolveBotToken = createResolveToken({
12
12
  envName: "HOLOCRON_DISCORD_BOT_TOKEN",
13
13
  vendorEnvName: "DISCORD_BOT_TOKEN",
14
- keyringService: "discord-bot",
15
- errorMessage: "no Discord bot token found. Set HOLOCRON_DISCORD_BOT_TOKEN (or DISCORD_BOT_TOKEN) — it is the bot token from the Discord developer portal (Bot → Reset Token), not a webhook URL."
14
+ keyringService: "discord.holonet",
15
+ errorMessage: "no Discord bot token found. Set HOLOCRON_DISCORD_BOT_TOKEN (or DISCORD_BOT_TOKEN), or run: holocron auth set discord.holonet <token> — it is the bot token from the Discord developer portal (Bot → Reset Token), not a webhook URL."
16
16
  });
17
17
  //#endregion
18
18
  //#region src/capabilities/notifications.ts
@@ -39,6 +39,21 @@ var DiscordNotifications = class DiscordNotifications {
39
39
  const { id, token } = parseWebhookUrl(webhookUrl);
40
40
  await this.client.webhooks.execute(id, token, message);
41
41
  }
42
+ /**
43
+ * `holocron doctor`: the bot token is valid and can see the configured server.
44
+ * Null when no `guildId` is set -- a post-only config has no bot to check. A
45
+ * `layout` without a `guildId` is a half-written provisioning config, so that
46
+ * fails instead of passing as post-only.
47
+ */
48
+ async whoami() {
49
+ if (!this.opts.guildId) {
50
+ if (this.opts.layout) throw new Error("`layout` is set but `guildId` is not — add the server id to the discord provider options");
51
+ return null;
52
+ }
53
+ const bot = this.bot();
54
+ const me = await bot.users.me();
55
+ return { target: `${(await bot.guilds.get(this.opts.guildId)).name} (as ${me.username})` };
56
+ }
42
57
  guild() {
43
58
  if (!this.opts.guildId) throw new Error("no Discord server id — set `guildId` in the discord provider options in holocron.config.ts");
44
59
  return this.opts.guildId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-discord",
3
- "version": "5.0.0-alpha.182",
3
+ "version": "5.0.0-alpha.184",
4
4
  "description": "Holocron plugin for Discord. Implements the notifications capability via Discord incoming webhooks.",
5
5
  "keywords": [
6
6
  "discord",
@@ -48,12 +48,12 @@
48
48
  "tsx": "4.23.15",
49
49
  "typescript": "^5.9.3",
50
50
  "vitest": "^4.1.11",
51
- "@theholocron/cli": "5.0.0-alpha.182"
51
+ "@theholocron/cli": "5.0.0-alpha.184"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@theholocron/discord-client": "^1.43.1",
55
55
  "@theholocron/misc-utils": "^1.16.0",
56
- "@theholocron/cli": "5.0.0-alpha.182"
56
+ "@theholocron/cli": "5.0.0-alpha.184"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=22"