@theholocron/holocron-plugin-discord 5.0.0-alpha.353 → 5.0.0-alpha.354
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 +1 -0
- package/dist/index.mjs +27 -2
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -263,6 +263,7 @@ export declare class DiscordNotifications implements Notifications {
|
|
|
263
263
|
access?: NotificationsAccess;
|
|
264
264
|
kind?: "text" | "forum";
|
|
265
265
|
tags?: NotificationsForumTag[];
|
|
266
|
+
defaultReaction?: string;
|
|
266
267
|
}): Promise<EnsuredResource>;
|
|
267
268
|
/** Finds the webhook with this name on the channel, or creates it; the optional avatar is the picture it posts with. */
|
|
268
269
|
ensureWebhook(input: {
|
package/dist/index.mjs
CHANGED
|
@@ -188,6 +188,7 @@ var DiscordDiscussions = class DiscordDiscussions {
|
|
|
188
188
|
...input.quiet ? { flags: MessageFlag.SuppressNotifications } : {}
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
|
+
await this.react(made.id, input.channel);
|
|
191
192
|
const thread = input.closed ? {
|
|
192
193
|
...made,
|
|
193
194
|
...await this.deps.bot().threads.modify(made.id, {
|
|
@@ -207,6 +208,14 @@ var DiscordDiscussions = class DiscordDiscussions {
|
|
|
207
208
|
created: true
|
|
208
209
|
};
|
|
209
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Puts the layout's starter reactions on the first message of a post just made (its id is the post's). One that
|
|
213
|
+
* fails (the bot lacks Add Reactions, an emoji Discord does not know) is skipped: the post is already made, and a
|
|
214
|
+
* missing reaction must not fail the sync.
|
|
215
|
+
*/
|
|
216
|
+
async react(post, channel) {
|
|
217
|
+
for (const emoji of this.deps.starterReactions?.(channel) ?? []) await this.deps.bot().channels.addReaction(post, post, emoji).catch(() => void 0);
|
|
218
|
+
}
|
|
210
219
|
/** The post for `key` (or the one `url` names, when the file moved), or `undefined`. It writes nothing. */
|
|
211
220
|
async read(channel, key, url) {
|
|
212
221
|
const forum = await this.forum(channel);
|
|
@@ -546,7 +555,8 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
546
555
|
...c.topic ? { topic: c.topic } : {},
|
|
547
556
|
...c.type === ChannelType.Forum ? {
|
|
548
557
|
kind: "forum",
|
|
549
|
-
tags: (c.available_tags ?? []).map(DiscordNotifications.tagOf)
|
|
558
|
+
tags: (c.available_tags ?? []).map(DiscordNotifications.tagOf),
|
|
559
|
+
...c.default_reaction_emoji?.emoji_name ? { defaultReaction: c.default_reaction_emoji.emoji_name } : {}
|
|
550
560
|
} : {},
|
|
551
561
|
webhooks,
|
|
552
562
|
webhookAvatars,
|
|
@@ -1008,7 +1018,8 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
1008
1018
|
return this.discussionStore ??= new DiscordDiscussions({
|
|
1009
1019
|
bot: () => this.bot(),
|
|
1010
1020
|
guild: () => this.guild(),
|
|
1011
|
-
channels: () => this.channelList()
|
|
1021
|
+
channels: () => this.channelList(),
|
|
1022
|
+
starterReactions: (channel) => (this.opts.layout?.categories ?? []).flatMap((c) => c.channels ?? []).find((c) => DiscordNotifications.same(c.name, channel))?.starterReactions ?? []
|
|
1012
1023
|
});
|
|
1013
1024
|
}
|
|
1014
1025
|
/** Finds the post for a document in a forum channel, or makes it. See {@link DiscordDiscussions}. */
|
|
@@ -1625,6 +1636,16 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
1625
1636
|
patch.available_tags = tags;
|
|
1626
1637
|
updated.push("tags");
|
|
1627
1638
|
}
|
|
1639
|
+
if (forum && input.defaultReaction !== void 0) {
|
|
1640
|
+
const have = existing.default_reaction_emoji;
|
|
1641
|
+
if (have?.emoji_name !== input.defaultReaction || have.emoji_id) {
|
|
1642
|
+
patch.default_reaction_emoji = {
|
|
1643
|
+
emoji_id: null,
|
|
1644
|
+
emoji_name: input.defaultReaction
|
|
1645
|
+
};
|
|
1646
|
+
updated.push("default reaction");
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1628
1649
|
if (parent && existing.parent_id !== parent) {
|
|
1629
1650
|
patch.parent_id = parent;
|
|
1630
1651
|
updated.push("category");
|
|
@@ -1649,6 +1670,10 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
1649
1670
|
name: input.name,
|
|
1650
1671
|
type: forum ? ChannelType.Forum : ChannelType.Text,
|
|
1651
1672
|
...forum && input.tags ? { available_tags: input.tags.map((t) => DiscordNotifications.tagInput(t)) } : {},
|
|
1673
|
+
...forum && input.defaultReaction ? { default_reaction_emoji: {
|
|
1674
|
+
emoji_id: null,
|
|
1675
|
+
emoji_name: input.defaultReaction
|
|
1676
|
+
} } : {},
|
|
1652
1677
|
...input.topic ? { topic: input.topic } : {},
|
|
1653
1678
|
...parent ? { parent_id: parent } : {},
|
|
1654
1679
|
...overwrites ? { permission_overwrites: overwrites } : {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-discord",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.354",
|
|
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.0.5",
|
|
44
|
-
"@theholocron/cli": "5.0.0-alpha.353",
|
|
45
44
|
"@theholocron/eslint-config": "^8.9.0-alpha.8",
|
|
46
|
-
"@theholocron/
|
|
45
|
+
"@theholocron/discord-client": "^1.58.0-alpha.11",
|
|
47
46
|
"@theholocron/misc-utils": "^1.17.0-alpha.1",
|
|
47
|
+
"@theholocron/http-client": "^1.58.0-alpha.11",
|
|
48
48
|
"@theholocron/tsconfig": "^8.9.0-alpha.8",
|
|
49
|
-
"@theholocron/
|
|
50
|
-
"@theholocron/
|
|
51
|
-
"@theholocron/
|
|
49
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.8",
|
|
50
|
+
"@theholocron/cli": "5.0.0-alpha.354",
|
|
51
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.8"
|
|
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.
|
|
56
|
+
"@theholocron/cli": "5.0.0-alpha.354"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22"
|