@theholocron/holocron-plugin-discord 5.0.0-alpha.371 → 5.0.0-alpha.373

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 (2) hide show
  1. package/dist/index.mjs +17 -4
  2. package/package.json +9 -9
package/dist/index.mjs CHANGED
@@ -215,7 +215,7 @@ var DiscordDiscussions = class DiscordDiscussions {
215
215
  applied_tags: [tag],
216
216
  message: {
217
217
  content,
218
- ...input.quiet ? { flags: MessageFlag.SuppressNotifications } : {}
218
+ ...this.flags(input.channel, input.quiet)
219
219
  }
220
220
  });
221
221
  await this.react(made.id, input.channel);
@@ -239,6 +239,15 @@ var DiscordDiscussions = class DiscordDiscussions {
239
239
  created: true
240
240
  };
241
241
  }
242
+ /** The `flags` a message in `channel` carries: no notification when `quiet`, no link previews in a feed forum. */
243
+ flags(channel, quiet) {
244
+ const flags = (quiet ? MessageFlag.SuppressNotifications : 0) | (this.deps.suppressEmbeds?.(channel) ? MessageFlag.SuppressEmbeds : 0);
245
+ return flags === 0 ? {} : { flags };
246
+ }
247
+ /** The `flags` of an edit: only the link previews can be changed on a message already sent. */
248
+ editFlags(channel) {
249
+ return this.deps.suppressEmbeds?.(channel) ? { flags: MessageFlag.SuppressEmbeds } : {};
250
+ }
242
251
  /**
243
252
  * Puts the layout's starter reactions on the first message of a post just made (its id is the post's). One that
244
253
  * fails (the bot lacks Add Reactions, an emoji Discord does not know) is skipped: the post is already made, and a
@@ -286,7 +295,10 @@ var DiscordDiscussions = class DiscordDiscussions {
286
295
  if (edited) {
287
296
  const synced = patch.synced ?? entry.synced ?? "";
288
297
  const content = withId.replace(FOOTER, () => `-# sync: ${nextKey} | ${synced}`);
289
- await bot.channels.editMessage(thread.id, thread.id, { content });
298
+ await bot.channels.editMessage(thread.id, thread.id, {
299
+ content,
300
+ ...this.editFlags(channel)
301
+ });
290
302
  entry.content = content;
291
303
  entry.synced = synced || void 0;
292
304
  if (nextKey !== key) {
@@ -324,7 +336,7 @@ var DiscordDiscussions = class DiscordDiscussions {
324
336
  const text = content.length > MAX_MESSAGE ? `${content.slice(0, 1999)}…` : content;
325
337
  await bot.channels.createMessage(entry.thread.id, {
326
338
  content: text,
327
- ...opts.quiet ? { flags: MessageFlag.SuppressNotifications } : {}
339
+ ...this.flags(channel, opts.quiet)
328
340
  });
329
341
  } finally {
330
342
  if (reopen) entry.thread = {
@@ -1174,7 +1186,8 @@ var DiscordNotifications = class DiscordNotifications {
1174
1186
  bot: () => this.bot(),
1175
1187
  guild: () => this.guild(),
1176
1188
  channels: () => this.channelList(),
1177
- starterReactions: (channel) => (this.opts.layout?.categories ?? []).flatMap((c) => c.channels ?? []).find((c) => DiscordNotifications.same(c.name, channel))?.starterReactions ?? []
1189
+ starterReactions: (channel) => (this.opts.layout?.categories ?? []).flatMap((c) => c.channels ?? []).find((c) => DiscordNotifications.same(c.name, channel))?.starterReactions ?? [],
1190
+ suppressEmbeds: (channel) => Boolean((this.opts.layout?.categories ?? []).flatMap((c) => c.channels ?? []).find((c) => DiscordNotifications.same(c.name, channel))?.feeds?.prs)
1178
1191
  });
1179
1192
  }
1180
1193
  /** Finds the post for a document in a forum channel, or makes it. See {@link DiscordDiscussions}. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-discord",
3
- "version": "5.0.0-alpha.371",
3
+ "version": "5.0.0-alpha.373",
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.371",
45
- "@theholocron/discord-client": "^1.58.0-alpha.18",
46
- "@theholocron/tsconfig": "^8.9.0-alpha.11",
44
+ "@theholocron/discord-client": "^1.58.0-alpha.20",
45
+ "@theholocron/cli": "5.0.0-alpha.373",
46
+ "@theholocron/eslint-config": "^8.9.0-alpha.12",
47
47
  "@theholocron/misc-utils": "^1.17.0-alpha.2",
48
- "@theholocron/http-client": "^1.58.0-alpha.18",
49
- "@theholocron/eslint-config": "^8.9.0-alpha.11",
50
- "@theholocron/vitest-config": "^8.9.0-alpha.11",
51
- "@theholocron/tsdown-config": "^8.9.0-alpha.11"
48
+ "@theholocron/tsdown-config": "^8.9.0-alpha.12",
49
+ "@theholocron/http-client": "^1.58.0-alpha.20",
50
+ "@theholocron/vitest-config": "^8.9.0-alpha.12",
51
+ "@theholocron/tsconfig": "^8.9.0-alpha.12"
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.371"
56
+ "@theholocron/cli": "5.0.0-alpha.373"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=22"