@theholocron/holocron-plugin-discord 5.0.0-alpha.192 → 5.0.0-alpha.193
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.mjs +16 -2
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -352,11 +352,19 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
352
352
|
set("contentFilter", "explicit_content_filter", s_(settings.contentFilter, FILTER), guild.explicit_content_filter);
|
|
353
353
|
set("systemChannel", "system_channel_id", settings.systemChannel && idOf(settings.systemChannel), guild.system_channel_id);
|
|
354
354
|
set("rulesChannel", "rules_channel_id", settings.rulesChannel && idOf(settings.rulesChannel), guild.rules_channel_id);
|
|
355
|
-
|
|
355
|
+
const updatesId = settings.updatesChannel ? idOf(settings.updatesChannel) : void 0;
|
|
356
|
+
const updatesChanged = updatesId !== void 0 && updatesId !== guild.public_updates_channel_id;
|
|
356
357
|
set("description", "description", settings.description, guild.description ?? "");
|
|
357
358
|
set("locale", "preferred_locale", settings.locale, guild.preferred_locale);
|
|
358
359
|
const community = (guild.features ?? []).includes("COMMUNITY");
|
|
359
360
|
const toggleCommunity = settings.community !== void 0 && settings.community !== community;
|
|
361
|
+
const updatesWithCommunity = updatesId !== void 0 && toggleCommunity && settings.community === true;
|
|
362
|
+
const communityAfter = toggleCommunity ? settings.community === true : community;
|
|
363
|
+
if (updatesChanged && !updatesWithCommunity) {
|
|
364
|
+
if (!communityAfter) throw new Error(`\`updatesChannel\` can only be set while community features are on, but they are off and the layout does not turn them on -- add \`community: true\` or remove \`updatesChannel\``);
|
|
365
|
+
patch.public_updates_channel_id = updatesId;
|
|
366
|
+
updated.push("updatesChannel");
|
|
367
|
+
}
|
|
360
368
|
const ordinary = async () => {
|
|
361
369
|
if (Object.keys(patch).length === 0) return;
|
|
362
370
|
let after;
|
|
@@ -377,7 +385,10 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
377
385
|
const wanted = settings.community ? [.../* @__PURE__ */ new Set([...fresh, "COMMUNITY"])] : fresh.filter((f) => f !== "COMMUNITY");
|
|
378
386
|
let after;
|
|
379
387
|
try {
|
|
380
|
-
after = await bot.guilds.modify(this.guild(), {
|
|
388
|
+
after = await bot.guilds.modify(this.guild(), {
|
|
389
|
+
features: wanted,
|
|
390
|
+
...updatesWithCommunity ? { public_updates_channel_id: updatesId } : {}
|
|
391
|
+
});
|
|
381
392
|
} catch (err) {
|
|
382
393
|
throw await this.communityHint(err, updated, settings.community === true);
|
|
383
394
|
}
|
|
@@ -387,6 +398,8 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
387
398
|
const lost = fresh.filter((f) => f !== "COMMUNITY" && !nowFeatures.includes(f));
|
|
388
399
|
if (lost.length > 0) throw new Error(`turned community on, but the server no longer has ${lost.join(", ")} -- another admin may have changed its features at the same time; check Server Settings and re-run`);
|
|
389
400
|
}
|
|
401
|
+
if (updatesWithCommunity && after.public_updates_channel_id !== updatesId) throw new Error(`${appliedPrefix(updated)}turned community on, but the server did not keep ${settings.updatesChannel} as its updates channel`);
|
|
402
|
+
if (updatesWithCommunity && updatesChanged) updated.push("updatesChannel");
|
|
390
403
|
updated.push("community");
|
|
391
404
|
};
|
|
392
405
|
if (toggleCommunity && settings.community === false) {
|
|
@@ -408,6 +421,7 @@ var DiscordNotifications = class DiscordNotifications {
|
|
|
408
421
|
const value = server?.[field];
|
|
409
422
|
if (value !== void 0 && !Object.hasOwn(map, value)) return `server: \`${field}\` is ${JSON.stringify(value)}; use one of ${Object.keys(map).join(", ")}`;
|
|
410
423
|
}
|
|
424
|
+
if (server?.community === false && server.updatesChannel !== void 0) return "server: `updatesChannel` can only be set while community features are on; remove it or set `community: true`";
|
|
411
425
|
if (server?.locale !== void 0 && !LOCALES.has(server.locale)) return `server: \`locale\` ${JSON.stringify(server.locale)} is not a locale Discord accepts (for example en-US, en-GB, de, fr)`;
|
|
412
426
|
if (server?.community === true && (server.verification === void 0 || server.verification === "none")) return "server: community features need `verification` of at least `low`";
|
|
413
427
|
if (server?.community === true && server.contentFilter !== "all") return "server: community features need `contentFilter: \"all\"`";
|
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.193",
|
|
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.193"
|
|
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.193"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22"
|