@theholocron/holocron-plugin-discord 5.0.0-alpha.196 → 5.0.0-alpha.197
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 +16 -9
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -216,9 +216,12 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
216
216
|
const found = [];
|
|
217
217
|
for (const c of text) {
|
|
218
218
|
let webhooks = [];
|
|
219
|
+
let webhookAvatars = [];
|
|
219
220
|
let webhooksError;
|
|
220
221
|
if (wantsWebhook.has(c.name.toLowerCase())) try {
|
|
221
|
-
|
|
222
|
+
const hooks = await bot.channels.webhooks(c.id);
|
|
223
|
+
webhooks = hooks.map((w) => w.name ?? "");
|
|
224
|
+
webhookAvatars = hooks.filter((w) => w.avatar).map((w) => w.name ?? "");
|
|
222
225
|
} catch (err) {
|
|
223
226
|
webhooksError = reason(err);
|
|
224
227
|
}
|
|
@@ -228,6 +231,7 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
228
231
|
...category ? { category } : {},
|
|
229
232
|
...c.topic ? { topic: c.topic } : {},
|
|
230
233
|
webhooks,
|
|
234
|
+
webhookAvatars,
|
|
231
235
|
...webhooksError ? { webhooksError } : {}
|
|
232
236
|
});
|
|
233
237
|
}
|
|
@@ -872,15 +876,18 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
872
876
|
const channel = DiscordNotifications.findChannel(await this.channelList(), input.channel, parent);
|
|
873
877
|
if (!channel) throw new Error(`no channel named \`${input.channel}\` — create it first`);
|
|
874
878
|
const existing = (await bot.channels.webhooks(channel.id)).find((w) => DiscordNotifications.same(w.name ?? "", input.name));
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
const made = await bot.channels.createWebhook(channel.id, { name: input.name });
|
|
880
|
-
return {
|
|
881
|
-
created: true,
|
|
882
|
-
...made.url ? { url: made.url } : {}
|
|
879
|
+
const hook = existing ?? await bot.channels.createWebhook(channel.id, { name: input.name });
|
|
880
|
+
const result = {
|
|
881
|
+
created: !existing,
|
|
882
|
+
...hook.url ? { url: hook.url } : {}
|
|
883
883
|
};
|
|
884
|
+
if (input.avatar !== void 0 && !hook.avatar) try {
|
|
885
|
+
await bot.webhooks.modify(hook.id, { avatar: input.avatar });
|
|
886
|
+
result.updated = ["avatar"];
|
|
887
|
+
} catch (err) {
|
|
888
|
+
result.avatarError = reason(err);
|
|
889
|
+
}
|
|
890
|
+
return result;
|
|
884
891
|
}
|
|
885
892
|
async ensureRole(input) {
|
|
886
893
|
const bot = this.bot();
|
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.197",
|
|
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.
|
|
51
|
+
"@theholocron/cli": "5.0.0-alpha.197"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@theholocron/discord-client": "^1.44.0",
|
|
55
55
|
"@theholocron/misc-utils": "^1.16.0",
|
|
56
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
56
|
+
"@theholocron/cli": "5.0.0-alpha.197"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22"
|