@theholocron/holocron-plugin-discord 5.0.0-alpha.406 → 5.0.0-alpha.407

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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ import { AuthError, DiscussionPatch, DiscussionPost, DuplicateDiscussion, 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
2
  import { DiscordBotClient, DiscordClient, DiscordClientOptions, DiscordOAuthClient, DiscordWebhookInfo, createDiscordClient, parseWebhookUrl } from "@theholocron/discord-client";
3
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
4
  export declare const resolveToken: import("@theholocron/cli").TokenResolver;
@@ -178,6 +178,8 @@ export declare class DiscordNotifications implements Notifications {
178
178
  dedupeDiscussion(channel: string, key: string, opts?: {
179
179
  refresh?: boolean;
180
180
  }): Promise<number>;
181
+ /** The keys with more than one post in a forum, with how many are beyond the oldest. Deletes nothing. */
182
+ duplicateDiscussions(channel: string): Promise<DuplicateDiscussion[]>;
181
183
  /**
182
184
  * Posts `content` (up to 2000 characters) in a text channel as the bot, without letting it mention anyone. A `#name`
183
185
  * that is one of the server's channels is linked.
package/dist/index.mjs CHANGED
@@ -354,6 +354,15 @@ var DiscordDiscussions = class DiscordDiscussions {
354
354
  if (!entry) return [];
355
355
  return (await this.deps.bot().channels.messages(entry.thread.id, Math.min(Math.max(limit, 1), 100))).map((m) => m.content);
356
356
  }
357
+ /** The keys with more than one post in the forum, read afresh, with how many are beyond the oldest. Deletes nothing. */
358
+ async duplicates(channel) {
359
+ const forum = await this.forum(channel);
360
+ this.forums.delete(forum.id);
361
+ return [...(await this.posts(forum)).values()].filter((entry) => entry.duplicates.length > 0).map((entry) => ({
362
+ key: entry.key,
363
+ extra: entry.duplicates.length
364
+ })).sort((a, b) => a.key.localeCompare(b.key));
365
+ }
357
366
  /** Keep the oldest post that carries `key` and delete the others. Returns how many were deleted. */
358
367
  async dedupe(channel, key, opts = {}) {
359
368
  const forum = await this.forum(channel);
@@ -1216,6 +1225,10 @@ var DiscordNotifications = class DiscordNotifications {
1216
1225
  dedupeDiscussion(channel, key, opts) {
1217
1226
  return this.discussions().dedupe(channel, key, opts);
1218
1227
  }
1228
+ /** The keys with more than one post in a forum, with how many are beyond the oldest. Deletes nothing. */
1229
+ duplicateDiscussions(channel) {
1230
+ return this.discussions().duplicates(channel);
1231
+ }
1219
1232
  /**
1220
1233
  * Posts `content` (up to 2000 characters) in a text channel as the bot, without letting it mention anyone. A `#name`
1221
1234
  * that is one of the server's channels is linked.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-discord",
3
- "version": "5.0.0-alpha.406",
3
+ "version": "5.0.0-alpha.407",
4
4
  "description": "Holocron plugin for Discord. Implements the notifications capability via Discord incoming webhooks.",
5
5
  "keywords": [
6
6
  "discord",
@@ -41,19 +41,19 @@
41
41
  "tsx": "4.23.15",
42
42
  "typescript": "^5.9.3",
43
43
  "vitest": "^5.1.0",
44
+ "@theholocron/cli": "5.0.0-alpha.407",
44
45
  "@theholocron/discord-client": "^1.58.0-alpha.27",
45
- "@theholocron/cli": "5.0.0-alpha.406",
46
46
  "@theholocron/eslint-config": "^8.9.0-alpha.16",
47
- "@theholocron/http-client": "^1.58.0-alpha.27",
48
47
  "@theholocron/misc-utils": "^1.17.0-alpha.3",
49
48
  "@theholocron/tsconfig": "^8.9.0-alpha.16",
49
+ "@theholocron/http-client": "^1.58.0-alpha.27",
50
50
  "@theholocron/tsdown-config": "^8.9.0-alpha.16",
51
51
  "@theholocron/vitest-config": "^8.9.0-alpha.16"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@theholocron/discord-client": "^1.50.0",
55
55
  "@theholocron/misc-utils": "^1.16.0",
56
- "@theholocron/cli": "5.0.0-alpha.406"
56
+ "@theholocron/cli": "5.0.0-alpha.407"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=22"