From 48d56965522cd4e95d162b161c2957a8ecfd6fb6 Mon Sep 17 00:00:00 2001 From: Tiago R Date: Fri, 22 Dec 2023 20:21:22 +0000 Subject: [PATCH 01/25] add missing "where" Signed-off-by: GitHub --- backend/src/data/GuildCounters.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/data/GuildCounters.ts b/backend/src/data/GuildCounters.ts index 4e69857b..fc853367 100644 --- a/backend/src/data/GuildCounters.ts +++ b/backend/src/data/GuildCounters.ts @@ -285,7 +285,11 @@ export class GuildCounters extends BaseGuildRepository { reverse_comparison_value: reverseComparisonValue, }); - return (await entityManager.findOne(CounterTrigger, insertResult.identifiers[0].id))!; + return (await entityManager.findOne(CounterTrigger, { + where: { + id: insertResult.identifiers[0].id + } + }))!; }); } From 94a712832a0e429cb8d96a5034e54eae82079bdb Mon Sep 17 00:00:00 2001 From: Tiago R Date: Wed, 27 Dec 2023 18:20:48 +0000 Subject: [PATCH 02/25] Display available emojis separately from total on server info (#433) * respect .available (almeida-approved code!!) Signed-off-by: GitHub * Update backend/src/plugins/Utility/functions/getServerInfoEmbed.ts Co-authored-by: Almeida --------- Signed-off-by: GitHub Co-authored-by: Almeida --- .../src/plugins/Utility/functions/getServerInfoEmbed.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Utility/functions/getServerInfoEmbed.ts b/backend/src/plugins/Utility/functions/getServerInfoEmbed.ts index 37050613..d0202db7 100644 --- a/backend/src/plugins/Utility/functions/getServerInfoEmbed.ts +++ b/backend/src/plugins/Utility/functions/getServerInfoEmbed.ts @@ -205,9 +205,14 @@ export async function getServerInfoEmbed( [GuildPremiumTier.Tier3]: 60, }[restGuild.premiumTier] ?? 0; + const availableEmojis = restGuild.emojis.cache.filter((e) => e.available); otherStats.push( - `Emojis: **${restGuild.emojis.cache.size}** / ${maxEmojis * 2}${ + `Emojis: **${availableEmojis.size}** / ${maxEmojis * 2}${ roleLockedEmojis ? ` (__${roleLockedEmojis} role-locked__)` : "" + }${ + availableEmojis.size < restGuild.emojis.cache.size + ? ` (__+${restGuild.emojis.cache.size - availableEmojis.size} unavailable__)` + : "" }`, ); otherStats.push(`Stickers: **${restGuild.stickers.cache.size}** / ${maxStickers}`); From cf55eb161f4e2adc7cb5e7c7060b5603b06e96dc Mon Sep 17 00:00:00 2001 From: Almeida Date: Wed, 27 Dec 2023 18:30:08 +0000 Subject: [PATCH 03/25] fix formatting and globs in package.json (#440) --- backend/src/data/GuildCounters.ts | 4 ++-- package.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/data/GuildCounters.ts b/backend/src/data/GuildCounters.ts index fc853367..0c8fde5b 100644 --- a/backend/src/data/GuildCounters.ts +++ b/backend/src/data/GuildCounters.ts @@ -287,8 +287,8 @@ export class GuildCounters extends BaseGuildRepository { return (await entityManager.findOne(CounterTrigger, { where: { - id: insertResult.identifiers[0].id - } + id: insertResult.identifiers[0].id, + }, }))!; }); } diff --git a/package.json b/package.json index 0cec2093..3250124d 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "description": "", "private": true, "scripts": { - "format": "prettier --write './backend/src/**/*.{css,html,js,json,ts,tsx}' './dashboard/src/**/*.{css,html,js,json,ts,tsx}'", - "lint": "eslint './backend/src/**/*.{js,ts,tsx}' './dashboard/src/**/*.{js,ts,tsx}'", - "codestyle-check": "prettier --check './backend/src/**/*.{css,html,js,json,ts,tsx}' './dashboard/src/**/*.{css,html,js,json,ts,tsx}'" + "format": "prettier --write \"./backend/src/**/*.{css,html,js,json,ts,tsx}\" \"./dashboard/src/**/*.{css,html,js,json,ts,tsx}\"", + "lint": "eslint \"./backend/src/**/*.{js,ts,tsx}\" \"./dashboard/src/**/*.{js,ts,tsx}\"", + "codestyle-check": "prettier --check \"./backend/src/**/*.{css,html,js,json,ts,tsx}\" \"./dashboard/src/**/*.{css,html,js,json,ts,tsx}\"" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.59.5", From e5e574625a2ee7442c01df2e5da1117754b27ed0 Mon Sep 17 00:00:00 2001 From: zay <87788699+zayKenyon@users.noreply.github.com> Date: Wed, 27 Dec 2023 18:33:20 +0000 Subject: [PATCH 04/25] chore(basic-config): rename plugin (#359) --- dashboard/src/components/docs/ConfigurationFormat.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src/components/docs/ConfigurationFormat.vue b/dashboard/src/components/docs/ConfigurationFormat.vue index 1d790ffa..426563e1 100644 --- a/dashboard/src/components/docs/ConfigurationFormat.vue +++ b/dashboard/src/components/docs/ConfigurationFormat.vue @@ -20,7 +20,7 @@ "172950000412655616": 50 # Example mod plugins: - mod_plugin: + mod_actions: config: kick_message: 'You have been kicked' can_kick: false From f17232e0c142012cf236443b8f03cbcb3cea1e3d Mon Sep 17 00:00:00 2001 From: Tiago R Date: Wed, 27 Dec 2023 18:35:16 +0000 Subject: [PATCH 05/25] dont allow self targeting for set-perms (#434) Signed-off-by: GitHub --- backend/src/api/guilds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/api/guilds.ts b/backend/src/api/guilds.ts index ba937093..4fef738f 100644 --- a/backend/src/api/guilds.ts +++ b/backend/src/api/guilds.ts @@ -126,7 +126,7 @@ export function initGuildsAPI(app: express.Express) { if (type !== ApiPermissionTypes.User) { return clientError(res, "Invalid type"); } - if (!isSnowflake(targetId)) { + if (!isSnowflake(targetId) || targetId === req.user!.userId) { return clientError(res, "Invalid targetId"); } const validPermissions = new Set(Object.values(ApiPermissions)); From 00fb71f26d2772904ef6fb89312161fcd922ef1a Mon Sep 17 00:00:00 2001 From: Tiago R Date: Wed, 27 Dec 2023 18:36:37 +0000 Subject: [PATCH 06/25] compose: Don't expose MySQL through all interfaces (#435) Signed-off-by: GitHub --- docker-compose.production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.production.yml b/docker-compose.production.yml index 672b9044..7dfc145b 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -21,7 +21,7 @@ services: MYSQL_USER: zeppelin MYSQL_PASSWORD: ${DOCKER_PROD_MYSQL_PASSWORD?:Missing DOCKER_PROD_MYSQL_PASSWORD} ports: - - ${DOCKER_PROD_MYSQL_PORT:?Missing DOCKER_PROD_MYSQL_PORT}:3306 + - 127.0.0.1:${DOCKER_PROD_MYSQL_PORT:?Missing DOCKER_PROD_MYSQL_PORT}:3306 volumes: - ./docker/production/data/mysql:/var/lib/mysql command: --authentication-policy=mysql_native_password From d162418be5288edcca7483acac089c2ff6da130e Mon Sep 17 00:00:00 2001 From: Tiago R Date: Wed, 27 Dec 2023 18:38:26 +0000 Subject: [PATCH 07/25] Add missing dependency to mutes plugin & fix timeout expiry (#430) * +debug Signed-off-by: GitHub * Revert "+debug" This reverts commit 83daee09d9e63ad0c162f4ec30d42b03ab4bdc7f. * add missing dependency to mutes Signed-off-by: GitHub * lower max timeout duration Signed-off-by: GitHub --------- Signed-off-by: GitHub --- backend/src/data/Mutes.ts | 2 +- backend/src/plugins/Mutes/MutesPlugin.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/data/Mutes.ts b/backend/src/data/Mutes.ts index ec7f11cc..ad50dcee 100644 --- a/backend/src/data/Mutes.ts +++ b/backend/src/data/Mutes.ts @@ -8,7 +8,7 @@ import { Mute } from "./entities/Mute"; const OLD_EXPIRED_MUTE_THRESHOLD = 7 * DAYS; -export const MAX_TIMEOUT_DURATION = 28 * DAYS; +export const MAX_TIMEOUT_DURATION = 27 * DAYS; // When a timeout is under this duration but the mute expires later, the timeout will be reset to max duration export const TIMEOUT_RENEWAL_THRESHOLD = 21 * DAYS; diff --git a/backend/src/plugins/Mutes/MutesPlugin.ts b/backend/src/plugins/Mutes/MutesPlugin.ts index 1a205bbe..ddc347ec 100644 --- a/backend/src/plugins/Mutes/MutesPlugin.ts +++ b/backend/src/plugins/Mutes/MutesPlugin.ts @@ -8,6 +8,7 @@ import { GuildMutes } from "../../data/GuildMutes"; import { makeIoTsConfigParser, mapToPublicFn } from "../../pluginUtils"; import { CasesPlugin } from "../Cases/CasesPlugin"; import { LogsPlugin } from "../Logs/LogsPlugin"; +import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin.js"; import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint"; import { ClearBannedMutesCmd } from "./commands/ClearBannedMutesCmd"; import { ClearMutesCmd } from "./commands/ClearMutesCmd"; @@ -68,7 +69,7 @@ export const MutesPlugin = zeppelinGuildPlugin()({ configSchema: ConfigSchema, }, - dependencies: () => [CasesPlugin, LogsPlugin], + dependencies: () => [CasesPlugin, LogsPlugin, RoleManagerPlugin], configParser: makeIoTsConfigParser(ConfigSchema), defaultOptions, From 047ab872df05f986564f6e465f9cc7deca65ca27 Mon Sep 17 00:00:00 2001 From: Almeida Date: Wed, 27 Dec 2023 18:44:35 +0000 Subject: [PATCH 08/25] fix parsing of file extension in match_attachment_type trigger (#425) --- backend/src/plugins/Automod/triggers/matchAttachmentType.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Automod/triggers/matchAttachmentType.ts b/backend/src/plugins/Automod/triggers/matchAttachmentType.ts index 659be65b..bb6c06fe 100644 --- a/backend/src/plugins/Automod/triggers/matchAttachmentType.ts +++ b/backend/src/plugins/Automod/triggers/matchAttachmentType.ts @@ -1,5 +1,6 @@ import { escapeInlineCode, Snowflake } from "discord.js"; import * as t from "io-ts"; +import { extname } from "path"; import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils"; import { automodTrigger } from "../helpers"; @@ -33,7 +34,7 @@ export const MatchAttachmentTypeTrigger = automodTrigger()({ } for (const attachment of context.message.data.attachments) { - const attachmentType = attachment.url.split(".").pop()!.toLowerCase(); + const attachmentType = extname(new URL(attachment.url).pathname).slice(1).toLowerCase(); const blacklist = trigger.blacklist_enabled ? (trigger.filetype_blacklist || []).map((_t) => _t.toLowerCase()) From 8860d4fb22e175a543332c6b880427508e09411f Mon Sep 17 00:00:00 2001 From: Tiago R Date: Thu, 28 Dec 2023 14:41:32 +0000 Subject: [PATCH 09/25] Timeouts: better validations (#438) * better timeout validations Signed-off-by: GitHub * almeida reviews Signed-off-by: GitHub * better error handling Signed-off-by: GitHub * add missing catch noops Signed-off-by: GitHub --------- Signed-off-by: GitHub --- backend/src/RecoverablePluginError.ts | 4 ++++ .../events/ReapplyActiveMuteOnJoinEvt.ts | 12 ++++++++-- .../src/plugins/Mutes/functions/muteUser.ts | 22 +++++++++++++++++-- .../Mutes/functions/renewTimeoutMute.ts | 12 ++++++++-- .../src/plugins/Mutes/functions/unmuteUser.ts | 8 ++++--- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/backend/src/RecoverablePluginError.ts b/backend/src/RecoverablePluginError.ts index b621fd41..46a86ae5 100644 --- a/backend/src/RecoverablePluginError.ts +++ b/backend/src/RecoverablePluginError.ts @@ -9,6 +9,8 @@ export enum ERRORS { INVALID_USER, INVALID_MUTE_ROLE_ID, MUTE_ROLE_ABOVE_ZEP, + USER_ABOVE_ZEP, + USER_NOT_MODERATABLE, } export const RECOVERABLE_PLUGIN_ERROR_MESSAGES = { @@ -20,6 +22,8 @@ export const RECOVERABLE_PLUGIN_ERROR_MESSAGES = { [ERRORS.INVALID_USER]: "Invalid user", [ERRORS.INVALID_MUTE_ROLE_ID]: "Specified mute role is not valid", [ERRORS.MUTE_ROLE_ABOVE_ZEP]: "Specified mute role is above Zeppelin in the role hierarchy", + [ERRORS.USER_ABOVE_ZEP]: "Cannot mute user, specified user is above Zeppelin in the role hierarchy", + [ERRORS.USER_NOT_MODERATABLE]: "Cannot mute user, specified user is not moderatable", }; export class RecoverablePluginError extends Error { diff --git a/backend/src/plugins/Mutes/events/ReapplyActiveMuteOnJoinEvt.ts b/backend/src/plugins/Mutes/events/ReapplyActiveMuteOnJoinEvt.ts index a859f7ad..6db4f27c 100644 --- a/backend/src/plugins/Mutes/events/ReapplyActiveMuteOnJoinEvt.ts +++ b/backend/src/plugins/Mutes/events/ReapplyActiveMuteOnJoinEvt.ts @@ -1,5 +1,6 @@ import moment from "moment-timezone"; import { MuteTypes } from "../../../data/MuteTypes"; +import { noop } from "../../../utils.js"; import { LogsPlugin } from "../../Logs/LogsPlugin"; import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin"; import { getTimeoutExpiryTime } from "../functions/getTimeoutExpiryTime"; @@ -12,6 +13,7 @@ export const ReapplyActiveMuteOnJoinEvt = mutesEvt({ event: "guildMemberAdd", async listener({ pluginData, args: { member } }) { const mute = await pluginData.state.mutes.findExistingMuteForUserId(member.id); + const logs = pluginData.getPlugin(LogsPlugin); if (!mute) { return; } @@ -25,11 +27,17 @@ export const ReapplyActiveMuteOnJoinEvt = mutesEvt({ if (!member.isCommunicationDisabled()) { const expiresAt = mute.expires_at ? moment.utc(mute.expires_at).valueOf() : null; const timeoutExpiresAt = getTimeoutExpiryTime(expiresAt); - await member.disableCommunicationUntil(timeoutExpiresAt); + if (member.moderatable) { + await member.disableCommunicationUntil(timeoutExpiresAt).catch(noop); + } else { + logs.logBotAlert({ + body: `Cannot mute user, specified user is not moderatable`, + }); + } } } - pluginData.getPlugin(LogsPlugin).logMemberMuteRejoin({ + logs.logMemberMuteRejoin({ member, }); }, diff --git a/backend/src/plugins/Mutes/functions/muteUser.ts b/backend/src/plugins/Mutes/functions/muteUser.ts index fc864ada..575f96fb 100644 --- a/backend/src/plugins/Mutes/functions/muteUser.ts +++ b/backend/src/plugins/Mutes/functions/muteUser.ts @@ -13,6 +13,7 @@ import { TemplateSafeValueContainer, renderTemplate } from "../../../templateFor import { UserNotificationMethod, UserNotificationResult, + noop, notifyUser, resolveMember, resolveUser, @@ -108,7 +109,7 @@ export async function muteUser( if (zepRoles.size === 0 || !zepRoles.some((zepRole) => zepRole.position > actualMuteRole.position)) { lock.unlock(); logs.logBotAlert({ - body: `Cannot mute users, specified mute role is above Zeppelin in the role hierarchy`, + body: `Cannot mute user, specified mute role is above Zeppelin in the role hierarchy`, }); throw new RecoverablePluginError(ERRORS.MUTE_ROLE_ABOVE_ZEP, pluginData.guild); } @@ -117,7 +118,24 @@ export async function muteUser( pluginData.getPlugin(RoleManagerPlugin).addPriorityRole(member.id, muteRole!); } } else { - await member.disableCommunicationUntil(timeoutUntil); + if (!member.manageable) { + lock.unlock(); + logs.logBotAlert({ + body: `Cannot mute user, specified user is above Zeppelin in the role hierarchy`, + }); + throw new RecoverablePluginError(ERRORS.USER_ABOVE_ZEP, pluginData.guild); + } + + if (!member.moderatable) { + // redundant safety, since canActOn already checks this + lock.unlock(); + logs.logBotAlert({ + body: `Cannot mute user, specified user is not moderatable`, + }); + throw new RecoverablePluginError(ERRORS.USER_NOT_MODERATABLE, pluginData.guild); + } + + await member.disableCommunicationUntil(timeoutUntil).catch(noop); } // If enabled, move the user to the mute voice channel (e.g. afk - just to apply the voice perms from the mute role) diff --git a/backend/src/plugins/Mutes/functions/renewTimeoutMute.ts b/backend/src/plugins/Mutes/functions/renewTimeoutMute.ts index 57def080..8363cf9f 100644 --- a/backend/src/plugins/Mutes/functions/renewTimeoutMute.ts +++ b/backend/src/plugins/Mutes/functions/renewTimeoutMute.ts @@ -3,7 +3,8 @@ import { GuildPluginData } from "knub"; import moment from "moment-timezone"; import { MAX_TIMEOUT_DURATION } from "../../../data/Mutes"; import { Mute } from "../../../data/entities/Mute"; -import { DBDateFormat, resolveMember } from "../../../utils"; +import { DBDateFormat, noop, resolveMember } from "../../../utils"; +import { LogsPlugin } from "../../Logs/LogsPlugin.js"; import { MutesPluginType } from "../types"; export async function renewTimeoutMute(pluginData: GuildPluginData, mute: Mute) { @@ -24,6 +25,13 @@ export async function renewTimeoutMute(pluginData: GuildPluginData Date: Thu, 28 Dec 2023 20:14:26 +0000 Subject: [PATCH 10/25] Reworked automod "set_slowmode" action (#441) * initial * fixes Signed-off-by: GitHub --------- Signed-off-by: GitHub Co-authored-by: Almeida --- .../src/plugins/Automod/actions/setSlowmode.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/src/plugins/Automod/actions/setSlowmode.ts b/backend/src/plugins/Automod/actions/setSlowmode.ts index 7b527f10..abd27f8a 100644 --- a/backend/src/plugins/Automod/actions/setSlowmode.ts +++ b/backend/src/plugins/Automod/actions/setSlowmode.ts @@ -6,7 +6,7 @@ import { automodAction } from "../helpers"; export const SetSlowmodeAction = automodAction({ configType: t.type({ - channels: t.array(t.string), + channels: tNullable(t.array(t.string)), duration: tNullable(tDelayString), }), @@ -14,14 +14,17 @@ export const SetSlowmodeAction = automodAction({ duration: "10s", }, - async apply({ pluginData, actionConfig }) { + async apply({ pluginData, actionConfig, contexts }) { const slowmodeMs = Math.max(actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : 0, 0); - - for (const channelId of actionConfig.channels) { + const channels: Snowflake[] = actionConfig.channels ?? []; + if (channels.length === 0) { + channels.push(...contexts.filter((c) => c.message?.channel_id).map((c) => c.message!.channel_id)); + } + for (const channelId of channels) { const channel = pluginData.guild.channels.cache.get(channelId as Snowflake); - // Only text channels and text channels within categories support slowmodes - if (!channel || (!channel.isTextBased() && channel.type !== ChannelType.GuildCategory)) { + + if (!channel?.isTextBased() && channel?.type !== ChannelType.GuildCategory) { continue; } From b8812456409cc2328f4c00ede1b38fcbdf07365d Mon Sep 17 00:00:00 2001 From: rubyowo Date: Thu, 28 Dec 2023 20:36:56 +0000 Subject: [PATCH 11/25] feat: make update script exit if one of the commands fail (#415) * feat: make update script fail if merge conflict * stop on first error with bash command --------- Co-authored-by: Almeida --- update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/update.sh b/update.sh index 676f1449..1769c3c9 100755 --- a/update.sh +++ b/update.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e echo Updating Zeppelin... From d09e0566b3461dbe92a533fbf0c2b8e62fe092b9 Mon Sep 17 00:00:00 2001 From: BanTheNons Date: Thu, 28 Dec 2023 23:43:46 +0300 Subject: [PATCH 12/25] fix: reactions in the channel archiver command (#308) Co-authored-by: Almeida --- .../src/plugins/ChannelArchiver/commands/ArchiveChannelCmd.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/plugins/ChannelArchiver/commands/ArchiveChannelCmd.ts b/backend/src/plugins/ChannelArchiver/commands/ArchiveChannelCmd.ts index 13a72a87..3fc1b72b 100644 --- a/backend/src/plugins/ChannelArchiver/commands/ArchiveChannelCmd.ts +++ b/backend/src/plugins/ChannelArchiver/commands/ArchiveChannelCmd.ts @@ -82,9 +82,9 @@ export const ArchiveChannelCmd = channelArchiverCmd({ } } - if (message.reactions && Object.keys(message.reactions).length > 0) { + if (message.reactions.cache.size > 0) { const reactionCounts: string[] = []; - for (const [emoji, info] of Object.entries(message.reactions)) { + for (const [emoji, info] of message.reactions.cache) { reactionCounts.push(`${info.count}x ${emoji}`); } content += `\n-- Reactions: ${reactionCounts.join(", ")}`; From 7c946949d6fca80a24deaf14cd613c055a597881 Mon Sep 17 00:00:00 2001 From: Tiago R Date: Fri, 29 Dec 2023 11:43:36 +0000 Subject: [PATCH 13/25] automod match_link fixes (#432) * remove trailing dot from FQDN for TLD check Signed-off-by: GitHub * yeet all trailing characters from TLDs Signed-off-by: GitHub * oops Signed-off-by: GitHub * move dumb loop to regex replace Signed-off-by: GitHub --------- Signed-off-by: GitHub Co-authored-by: Almeida --- backend/src/utils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 1bb4d6ce..c6c705db 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -647,7 +647,13 @@ export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] { return urls; } - const hostnameParts = matchUrl.hostname.split("."); + let hostname = matchUrl.hostname.toLowerCase(); + + if (hostname.length > 3) { + hostname = hostname.replace(/[^a-z]+$/, ""); + } + + const hostnameParts = hostname.split("."); const tld = hostnameParts[hostnameParts.length - 1]; if (tlds.includes(tld)) { urls.push(matchUrl); From b2fc4d69e3205ed6e0690f3d2307f8944a43b7c0 Mon Sep 17 00:00:00 2001 From: Miikka <2606411+Dragory@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:21:58 +0200 Subject: [PATCH 14/25] chore: update .clabot --- .clabot | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.clabot b/.clabot index 381bf599..0dcbf7f3 100644 --- a/.clabot +++ b/.clabot @@ -23,7 +23,11 @@ "iamshoXy", "Scraayp", "app/dependabot", - "zayKenyon" + "zayKenyon", + "rukogit", + "Obliie", + "brawaru", + "Benricheson101" ], "message": "Thank you for contributing to Zeppelin! We require contributors to sign our Contributor License Agreement (CLA). To let us review and merge your code, please visit https://github.com/ZeppelinBot/CLA to sign the CLA!" } From e7eacb330b4d21962ecbf8d4eff6905e86b0365e Mon Sep 17 00:00:00 2001 From: Miikka <2606411+Dragory@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:26:20 +0200 Subject: [PATCH 15/25] chore: update .clabot --- .clabot | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.clabot b/.clabot index 0dcbf7f3..43dcfc5f 100644 --- a/.clabot +++ b/.clabot @@ -27,7 +27,8 @@ "rukogit", "Obliie", "brawaru", - "Benricheson101" + "Benricheson101", + "hawkeye7662" ], "message": "Thank you for contributing to Zeppelin! We require contributors to sign our Contributor License Agreement (CLA). To let us review and merge your code, please visit https://github.com/ZeppelinBot/CLA to sign the CLA!" } From 1cb8431a02476d88f90d21105e46d53a178b65c6 Mon Sep 17 00:00:00 2001 From: hawkeye7662 <82515230+hawkeye7662@users.noreply.github.com> Date: Fri, 29 Dec 2023 17:59:28 +0530 Subject: [PATCH 16/25] Fix loose matching for automod (#428) Added a missing closing bracket for the regex to work. Co-authored-by: Almeida --- backend/src/plugins/Automod/triggers/matchWords.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/plugins/Automod/triggers/matchWords.ts b/backend/src/plugins/Automod/triggers/matchWords.ts index c5ca79fc..1deb64e5 100644 --- a/backend/src/plugins/Automod/triggers/matchWords.ts +++ b/backend/src/plugins/Automod/triggers/matchWords.ts @@ -54,7 +54,7 @@ export const MatchWordsTrigger = automodTrigger()({ const looseMatchingThreshold = Math.min(Math.max(trigger.loose_matching_threshold, 1), 64); const patterns = trigger.words.map((word) => { let pattern = trigger.loose_matching - ? [...word].map((c) => escapeStringRegexp(c)).join(`(?:\\s*|.{0,${looseMatchingThreshold})`) + ? [...word].map((c) => escapeStringRegexp(c)).join(`(?:\\s*|.{0,${looseMatchingThreshold}})`) : escapeStringRegexp(word); if (trigger.only_full_words) { From d51461ee3af2a1229578817c2169bdfd2f4ec243 Mon Sep 17 00:00:00 2001 From: hawkeye7662 <82515230+hawkeye7662@users.noreply.github.com> Date: Fri, 29 Dec 2023 18:02:48 +0530 Subject: [PATCH 17/25] Catch Too Many Reactions error (#326) Catches Maximum number of reactions reached (20) error by checking for error code 30010 Co-authored-by: Almeida --- .../util/applyReactionRoleReactionsToMessage.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/plugins/ReactionRoles/util/applyReactionRoleReactionsToMessage.ts b/backend/src/plugins/ReactionRoles/util/applyReactionRoleReactionsToMessage.ts index 94de8631..5d1b3a37 100644 --- a/backend/src/plugins/ReactionRoles/util/applyReactionRoleReactionsToMessage.ts +++ b/backend/src/plugins/ReactionRoles/util/applyReactionRoleReactionsToMessage.ts @@ -86,6 +86,12 @@ export async function applyReactionRoleReactionsToMessage( body: `Error ${e.code} while applying reaction role reactions to ${channelId}/${messageId}: ${e.message}`, }); break; + } else if (e.code === 30010) { + errors.push(`Maximum number of reactions reached (20)`); + logs.logBotAlert({ + body: `Error ${e.code} while applying reaction role reactions to ${channelId}/${messageId}: ${e.message}`, + }); + break; } } From 8a4a2d36478036e31f9b547e23d5bf5a31acff59 Mon Sep 17 00:00:00 2001 From: Ben Richeson <36977340+Benricheson101@users.noreply.github.com> Date: Fri, 29 Dec 2023 07:52:43 -0500 Subject: [PATCH 18/25] feat: option to trigger antiraid_level only on change (#424) Co-authored-by: Almeida --- .../plugins/Automod/events/runAutomodOnAntiraidLevel.ts | 6 ++++-- .../src/plugins/Automod/functions/setAntiraidLevel.ts | 3 ++- backend/src/plugins/Automod/triggers/antiraidLevel.ts | 9 +++++++++ backend/src/plugins/Automod/types.ts | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/backend/src/plugins/Automod/events/runAutomodOnAntiraidLevel.ts b/backend/src/plugins/Automod/events/runAutomodOnAntiraidLevel.ts index 2dfc4bac..05dbb6f3 100644 --- a/backend/src/plugins/Automod/events/runAutomodOnAntiraidLevel.ts +++ b/backend/src/plugins/Automod/events/runAutomodOnAntiraidLevel.ts @@ -5,13 +5,15 @@ import { AutomodContext, AutomodPluginType } from "../types"; export async function runAutomodOnAntiraidLevel( pluginData: GuildPluginData, - level: string | null, + newLevel: string | null, + oldLevel: string | null, user?: User, ) { const context: AutomodContext = { timestamp: Date.now(), antiraid: { - level, + level: newLevel, + oldLevel, }, user, }; diff --git a/backend/src/plugins/Automod/functions/setAntiraidLevel.ts b/backend/src/plugins/Automod/functions/setAntiraidLevel.ts index a21d58b0..c76555c2 100644 --- a/backend/src/plugins/Automod/functions/setAntiraidLevel.ts +++ b/backend/src/plugins/Automod/functions/setAntiraidLevel.ts @@ -9,10 +9,11 @@ export async function setAntiraidLevel( newLevel: string | null, user?: User, ) { + const oldLevel = pluginData.state.cachedAntiraidLevel; pluginData.state.cachedAntiraidLevel = newLevel; await pluginData.state.antiraidLevels.set(newLevel); - runAutomodOnAntiraidLevel(pluginData, newLevel, user); + runAutomodOnAntiraidLevel(pluginData, newLevel, oldLevel, user); const logs = pluginData.getPlugin(LogsPlugin); diff --git a/backend/src/plugins/Automod/triggers/antiraidLevel.ts b/backend/src/plugins/Automod/triggers/antiraidLevel.ts index 7c6d17af..f5caa3f0 100644 --- a/backend/src/plugins/Automod/triggers/antiraidLevel.ts +++ b/backend/src/plugins/Automod/triggers/antiraidLevel.ts @@ -7,6 +7,7 @@ interface AntiraidLevelTriggerResult {} export const AntiraidLevelTrigger = automodTrigger()({ configType: t.type({ level: tNullable(t.string), + only_on_change: tNullable(t.boolean), }), defaultConfig: {}, @@ -20,6 +21,14 @@ export const AntiraidLevelTrigger = automodTrigger() return; } + if ( + triggerConfig.only_on_change && + context.antiraid.oldLevel !== undefined && + context.antiraid.level === context.antiraid.oldLevel + ) { + return; + } + return { extra: {}, }; diff --git a/backend/src/plugins/Automod/types.ts b/backend/src/plugins/Automod/types.ts index bd3f05ee..b9900089 100644 --- a/backend/src/plugins/Automod/types.ts +++ b/backend/src/plugins/Automod/types.ts @@ -130,6 +130,7 @@ export interface AutomodContext { }; antiraid?: { level: string | null; + oldLevel?: string | null; }; threadChange?: { created?: ThreadChannel; From 3217f350178104a813a25ac9b488ae3e59ba9187 Mon Sep 17 00:00:00 2001 From: Tiago R Date: Fri, 29 Dec 2023 14:30:40 +0000 Subject: [PATCH 19/25] implement MEMBER_MUTE_EXPIRED (#437) Signed-off-by: GitHub --- backend/src/plugins/Mutes/functions/clearMute.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Mutes/functions/clearMute.ts b/backend/src/plugins/Mutes/functions/clearMute.ts index 0bef1881..f96068c7 100644 --- a/backend/src/plugins/Mutes/functions/clearMute.ts +++ b/backend/src/plugins/Mutes/functions/clearMute.ts @@ -57,9 +57,10 @@ export async function clearMute( await member.timeout(null); } } + pluginData.getPlugin(LogsPlugin).logMemberMuteExpired({ member }); } catch { pluginData.getPlugin(LogsPlugin).logBotAlert({ - body: `Failed to remove mute role from ${verboseUserMention(member.user)}`, + body: `Failed to clear mute from ${verboseUserMention(member.user)}`, }); } finally { lock.unlock(); From 3912523c920bff1772a5c58380d0525973239661 Mon Sep 17 00:00:00 2001 From: zay <87788699+zayKenyon@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:09:37 +0000 Subject: [PATCH 20/25] Moderation Guide (#356) * create Moderation Guide * code review * fix: enable mod_actions plugin * Apply suggestions from code review Co-authored-by: Almeida * style: code review Suggestions that were not automatically resolvable. --------- Co-authored-by: Almeida --- dashboard/src/components/docs/Moderation.vue | 156 +++++++++++++++++++ dashboard/src/routes.ts | 2 +- 2 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 dashboard/src/components/docs/Moderation.vue diff --git a/dashboard/src/components/docs/Moderation.vue b/dashboard/src/components/docs/Moderation.vue new file mode 100644 index 00000000..ff2151e6 --- /dev/null +++ b/dashboard/src/components/docs/Moderation.vue @@ -0,0 +1,156 @@ + + + diff --git a/dashboard/src/routes.ts b/dashboard/src/routes.ts index 15ac3d96..b70c38db 100644 --- a/dashboard/src/routes.ts +++ b/dashboard/src/routes.ts @@ -51,7 +51,7 @@ export const router = new VueRouter({ }, { path: "setup-guides/moderation", - component: () => import("./components/docs/WorkInProgress.vue"), + component: () => import("./components/docs/Moderation.vue"), }, { path: "setup-guides/counters", From 094e94f0f4226d9173aa9f344ae06494e31adabf Mon Sep 17 00:00:00 2001 From: Ben Richeson <36977340+Benricheson101@users.noreply.github.com> Date: Thu, 4 Jan 2024 20:41:12 -0500 Subject: [PATCH 21/25] Add `pause_invites` automod action (#423) * feat(AutomodPlugin): toggle invite action * feat: rename and change config shape * refactor: rename disable_invites to pause_invites * fix: make options an object, else setting an action to `false` ignores it --- .../plugins/Automod/actions/availableActions.ts | 3 +++ .../src/plugins/Automod/actions/pauseInvites.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 backend/src/plugins/Automod/actions/pauseInvites.ts diff --git a/backend/src/plugins/Automod/actions/availableActions.ts b/backend/src/plugins/Automod/actions/availableActions.ts index 3f253bc0..b77f3942 100644 --- a/backend/src/plugins/Automod/actions/availableActions.ts +++ b/backend/src/plugins/Automod/actions/availableActions.ts @@ -11,6 +11,7 @@ import { CleanAction } from "./clean"; import { KickAction } from "./kick"; import { LogAction } from "./log"; import { MuteAction } from "./mute"; +import { PauseInvitesAction } from "./pauseInvites"; import { RemoveRolesAction } from "./removeRoles"; import { ReplyAction } from "./reply"; import { SetAntiraidLevelAction } from "./setAntiraidLevel"; @@ -38,6 +39,7 @@ export const availableActions: Record> = { start_thread: StartThreadAction, archive_thread: ArchiveThreadAction, change_perms: ChangePermsAction, + pause_invites: PauseInvitesAction, }; export const AvailableActions = t.type({ @@ -59,4 +61,5 @@ export const AvailableActions = t.type({ start_thread: StartThreadAction.configType, archive_thread: ArchiveThreadAction.configType, change_perms: ChangePermsAction.configType, + pause_invites: PauseInvitesAction.configType, }); diff --git a/backend/src/plugins/Automod/actions/pauseInvites.ts b/backend/src/plugins/Automod/actions/pauseInvites.ts new file mode 100644 index 00000000..1bbea34f --- /dev/null +++ b/backend/src/plugins/Automod/actions/pauseInvites.ts @@ -0,0 +1,14 @@ +import * as t from "io-ts"; +import { automodAction } from "../helpers"; + +export const PauseInvitesAction = automodAction({ + configType: t.type({ + paused: t.boolean, + }), + + defaultConfig: {}, + + async apply({ pluginData, actionConfig }) { + await pluginData.guild.disableInvites(actionConfig.paused); + }, +}); From f58e7f5eb71a329d2b8e9dd08a79e17cc4d0717d Mon Sep 17 00:00:00 2001 From: Tiago R Date: Sun, 7 Jan 2024 21:12:50 +0000 Subject: [PATCH 22/25] Fix automod cooldown logic (#442) * fix automod cooldowns Signed-off-by: GitHub * almeida fixes Signed-off-by: GitHub * https://shr2.i0.tf/82e683c8/bd310b9c-7492-44f0-aed5-af6a22a3c196.png Signed-off-by: GitHub --------- Signed-off-by: GitHub --- .../Automod/functions/applyCooldown.ts | 10 ++++++++ .../functions/checkAndUpdateCooldown.ts | 24 ------------------- .../Automod/functions/checkCooldown.ts | 8 +++++++ .../plugins/Automod/functions/runAutomod.ts | 7 ++++-- 4 files changed, 23 insertions(+), 26 deletions(-) create mode 100644 backend/src/plugins/Automod/functions/applyCooldown.ts delete mode 100644 backend/src/plugins/Automod/functions/checkAndUpdateCooldown.ts create mode 100644 backend/src/plugins/Automod/functions/checkCooldown.ts diff --git a/backend/src/plugins/Automod/functions/applyCooldown.ts b/backend/src/plugins/Automod/functions/applyCooldown.ts new file mode 100644 index 00000000..387ac448 --- /dev/null +++ b/backend/src/plugins/Automod/functions/applyCooldown.ts @@ -0,0 +1,10 @@ +import { GuildPluginData } from "knub"; +import { convertDelayStringToMS } from "../../../utils"; +import { AutomodContext, AutomodPluginType, TRule } from "../types"; + +export function applyCooldown(pluginData: GuildPluginData, rule: TRule, context: AutomodContext) { + const cooldownKey = `${rule.name}-${context.user?.id}`; + + const cooldownTime = convertDelayStringToMS(rule.cooldown, "s"); + if (cooldownTime) pluginData.state.cooldownManager.setCooldown(cooldownKey, cooldownTime); +} diff --git a/backend/src/plugins/Automod/functions/checkAndUpdateCooldown.ts b/backend/src/plugins/Automod/functions/checkAndUpdateCooldown.ts deleted file mode 100644 index 6338d698..00000000 --- a/backend/src/plugins/Automod/functions/checkAndUpdateCooldown.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { GuildPluginData } from "knub"; -import { convertDelayStringToMS } from "../../../utils"; -import { AutomodContext, AutomodPluginType, TRule } from "../types"; - -export function checkAndUpdateCooldown( - pluginData: GuildPluginData, - rule: TRule, - context: AutomodContext, -) { - const cooldownKey = `${rule.name}-${context.user?.id}`; - - if (cooldownKey) { - if (pluginData.state.cooldownManager.isOnCooldown(cooldownKey)) { - return true; - } - - const cooldownTime = convertDelayStringToMS(rule.cooldown, "s"); - if (cooldownTime) { - pluginData.state.cooldownManager.setCooldown(cooldownKey, cooldownTime); - } - } - - return false; -} diff --git a/backend/src/plugins/Automod/functions/checkCooldown.ts b/backend/src/plugins/Automod/functions/checkCooldown.ts new file mode 100644 index 00000000..3640c142 --- /dev/null +++ b/backend/src/plugins/Automod/functions/checkCooldown.ts @@ -0,0 +1,8 @@ +import { GuildPluginData } from "knub"; +import { AutomodContext, AutomodPluginType, TRule } from "../types"; + +export function checkCooldown(pluginData: GuildPluginData, rule: TRule, context: AutomodContext) { + const cooldownKey = `${rule.name}-${context.user?.id}`; + + return pluginData.state.cooldownManager.isOnCooldown(cooldownKey); +} diff --git a/backend/src/plugins/Automod/functions/runAutomod.ts b/backend/src/plugins/Automod/functions/runAutomod.ts index e9c2e3a7..4ccc38de 100644 --- a/backend/src/plugins/Automod/functions/runAutomod.ts +++ b/backend/src/plugins/Automod/functions/runAutomod.ts @@ -7,7 +7,8 @@ import { CleanAction } from "../actions/clean"; import { AutomodTriggerMatchResult } from "../helpers"; import { availableTriggers } from "../triggers/availableTriggers"; import { AutomodContext, AutomodPluginType } from "../types"; -import { checkAndUpdateCooldown } from "./checkAndUpdateCooldown"; +import { applyCooldown } from "./applyCooldown"; +import { checkCooldown } from "./checkCooldown"; export async function runAutomod(pluginData: GuildPluginData, context: AutomodContext) { const userId = context.user?.id || context.member?.id || context.message?.user_id; @@ -46,7 +47,7 @@ export async function runAutomod(pluginData: GuildPluginData, } if (!rule.affects_self && userId && userId === pluginData.client.user?.id) continue; - if (rule.cooldown && checkAndUpdateCooldown(pluginData, rule, context)) { + if (rule.cooldown && checkCooldown(pluginData, rule, context)) { continue; } @@ -84,6 +85,8 @@ export async function runAutomod(pluginData: GuildPluginData, } if (matchResult) { + if (rule.cooldown) applyCooldown(pluginData, rule, context); + contexts = [context, ...(matchResult.extraContexts || [])]; for (const _context of contexts) { From 47ad8fa4d3329e0009d1a369d40740a7e6ae503e Mon Sep 17 00:00:00 2001 From: Almeida Date: Mon, 8 Jan 2024 11:15:57 +0000 Subject: [PATCH 23/25] only call `disableInvites()` if value has changed (#443) --- backend/src/plugins/Automod/actions/pauseInvites.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Automod/actions/pauseInvites.ts b/backend/src/plugins/Automod/actions/pauseInvites.ts index 1bbea34f..262b6912 100644 --- a/backend/src/plugins/Automod/actions/pauseInvites.ts +++ b/backend/src/plugins/Automod/actions/pauseInvites.ts @@ -1,3 +1,4 @@ +import { GuildFeature } from "discord.js"; import * as t from "io-ts"; import { automodAction } from "../helpers"; @@ -9,6 +10,10 @@ export const PauseInvitesAction = automodAction({ defaultConfig: {}, async apply({ pluginData, actionConfig }) { - await pluginData.guild.disableInvites(actionConfig.paused); + const hasInvitesDisabled = pluginData.guild.features.includes(GuildFeature.InvitesDisabled); + + if (actionConfig.paused !== hasInvitesDisabled) { + await pluginData.guild.disableInvites(actionConfig.paused); + } }, }); From c07e4321a72cbb58a6d9e05dc07e0bb5d9dd3e68 Mon Sep 17 00:00:00 2001 From: Almeida Date: Mon, 8 Jan 2024 15:35:55 +0000 Subject: [PATCH 24/25] remove erlpack (#444) --- backend/package-lock.json | 24 ------------------------ backend/package.json | 1 - 2 files changed, 25 deletions(-) diff --git a/backend/package-lock.json b/backend/package-lock.json index b1d6d189..2949ed98 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -17,7 +17,6 @@ "discord.js": "^14.11.0", "dotenv": "^4.0.0", "emoji-regex": "^8.0.0", - "erlpack": "github:discord/erlpack", "escape-string-regexp": "^1.0.5", "express": "^4.17.0", "fp-ts": "^2.0.1", @@ -1553,14 +1552,6 @@ "node": ">=8" } }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, "node_modules/bit-twiddle": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bit-twiddle/-/bit-twiddle-1.0.2.tgz", @@ -3467,16 +3458,6 @@ "resolved": "https://registry.npmjs.org/env-string/-/env-string-1.0.1.tgz", "integrity": "sha512-/DhCJDf5DSFK32joQiWRpWrT0h7p3hVQfMKxiBb7Nt8C8IF8BYyPtclDnuGGLOoj16d/8udKeiE7JbkotDmorQ==" }, - "node_modules/erlpack": { - "version": "0.1.3", - "resolved": "git+ssh://git@github.com/discord/erlpack.git#cbe76be04c2210fc9cb6ff95910f0937c1011d04", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.15.0" - } - }, "node_modules/es5-ext": { "version": "0.10.62", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", @@ -3941,11 +3922,6 @@ "url": "https://github.com/sindresorhus/file-type?sponsor=1" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", diff --git a/backend/package.json b/backend/package.json index 2ff53482..cf120ca5 100644 --- a/backend/package.json +++ b/backend/package.json @@ -38,7 +38,6 @@ "discord.js": "^14.11.0", "dotenv": "^4.0.0", "emoji-regex": "^8.0.0", - "erlpack": "github:discord/erlpack", "escape-string-regexp": "^1.0.5", "express": "^4.17.0", "fp-ts": "^2.0.1", From 39e8367f5fcbd890ba7a0b2a96e0598841f8e3f7 Mon Sep 17 00:00:00 2001 From: Tiago R Date: Mon, 15 Jan 2024 12:23:52 +0000 Subject: [PATCH 25/25] disable guildmembercache Signed-off-by: GitHub --- backend/src/plugins/Persist/PersistPlugin.ts | 3 +-- backend/src/plugins/Persist/events/StoreDataEvt.ts | 6 ++++-- backend/src/plugins/availablePlugins.ts | 5 ++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/plugins/Persist/PersistPlugin.ts b/backend/src/plugins/Persist/PersistPlugin.ts index ecd50067..bc914c44 100644 --- a/backend/src/plugins/Persist/PersistPlugin.ts +++ b/backend/src/plugins/Persist/PersistPlugin.ts @@ -3,7 +3,6 @@ import { GuildLogs } from "../../data/GuildLogs"; import { GuildPersistedData } from "../../data/GuildPersistedData"; import { makeIoTsConfigParser } from "../../pluginUtils"; import { trimPluginDescription } from "../../utils"; -import { GuildMemberCachePlugin } from "../GuildMemberCache/GuildMemberCachePlugin"; import { LogsPlugin } from "../Logs/LogsPlugin"; import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin"; import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint"; @@ -31,7 +30,7 @@ export const PersistPlugin = zeppelinGuildPlugin()({ configSchema: ConfigSchema, }, - dependencies: () => [LogsPlugin, RoleManagerPlugin, GuildMemberCachePlugin], + dependencies: () => [LogsPlugin, RoleManagerPlugin], configParser: makeIoTsConfigParser(ConfigSchema), defaultOptions, diff --git a/backend/src/plugins/Persist/events/StoreDataEvt.ts b/backend/src/plugins/Persist/events/StoreDataEvt.ts index 537c7b62..9385c279 100644 --- a/backend/src/plugins/Persist/events/StoreDataEvt.ts +++ b/backend/src/plugins/Persist/events/StoreDataEvt.ts @@ -1,5 +1,4 @@ import { PersistedData } from "../../../data/entities/PersistedData"; -import { GuildMemberCachePlugin } from "../../GuildMemberCache/GuildMemberCachePlugin"; import { persistEvt } from "../types"; export const StoreDataEvt = persistEvt({ @@ -9,8 +8,11 @@ export const StoreDataEvt = persistEvt({ const config = await pluginData.config.getForUser(member.user); const persistData: Partial = {}; + // FIXME: New caching thing, or fix deadlocks with this plugin if (member.partial) { + return; // Djs hasn't cached member data => use db cache + /* const data = await pluginData.getPlugin(GuildMemberCachePlugin).getCachedMemberData(member.id); if (!data) { return; @@ -22,7 +24,7 @@ export const StoreDataEvt = persistEvt({ } if (config.persist_nicknames && data.nickname) { persistData.nickname = data.nickname; - } + }*/ } else { // Djs has cached member data => use that const memberRoles = Array.from(member.roles.cache.keys()); diff --git a/backend/src/plugins/availablePlugins.ts b/backend/src/plugins/availablePlugins.ts index 58af41fc..3df9c347 100644 --- a/backend/src/plugins/availablePlugins.ts +++ b/backend/src/plugins/availablePlugins.ts @@ -12,7 +12,6 @@ import { CustomEventsPlugin } from "./CustomEvents/CustomEventsPlugin"; import { GuildAccessMonitorPlugin } from "./GuildAccessMonitor/GuildAccessMonitorPlugin"; import { GuildConfigReloaderPlugin } from "./GuildConfigReloader/GuildConfigReloaderPlugin"; import { GuildInfoSaverPlugin } from "./GuildInfoSaver/GuildInfoSaverPlugin"; -import { GuildMemberCachePlugin } from "./GuildMemberCache/GuildMemberCachePlugin"; import { InternalPosterPlugin } from "./InternalPoster/InternalPosterPlugin"; import { LocateUserPlugin } from "./LocateUser/LocateUserPlugin"; import { LogsPlugin } from "./Logs/LogsPlugin"; @@ -54,7 +53,7 @@ export const guildPlugins: Array> = [ PostPlugin, ReactionRolesPlugin, MessageSaverPlugin, - GuildMemberCachePlugin, + // GuildMemberCachePlugin, // FIXME: New caching thing, or fix deadlocks with this plugin ModActionsPlugin, NameHistoryPlugin, RemindersPlugin, @@ -93,7 +92,7 @@ export const baseGuildPlugins: Array> = [ GuildInfoSaverPlugin, MessageSaverPlugin, NameHistoryPlugin, - GuildMemberCachePlugin, + // GuildMemberCachePlugin, // FIXME: New caching thing, or fix deadlocks with this plugin CasesPlugin, MutesPlugin, TimeAndDatePlugin,