From ff160be1fa598250e96972d54f92dfea6b69f5d1 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 27 Nov 2021 11:52:26 +0200 Subject: [PATCH 01/15] fix(automod): don't try to reply with an empty message --- backend/src/plugins/Automod/actions/reply.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/src/plugins/Automod/actions/reply.ts b/backend/src/plugins/Automod/actions/reply.ts index efe833cb..52aa491d 100644 --- a/backend/src/plugins/Automod/actions/reply.ts +++ b/backend/src/plugins/Automod/actions/reply.ts @@ -17,6 +17,7 @@ import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions"; import { automodAction } from "../helpers"; import { AutomodContext } from "../types"; import { LogsPlugin } from "../../Logs/LogsPlugin"; +import { messageIsEmpty } from "../../../utils/messageIsEmpty"; export const ReplyAction = automodAction({ configType: t.union([ @@ -109,6 +110,10 @@ export const ReplyAction = automodAction({ }; } + if (messageIsEmpty(messageOpts)) { + return; + } + const replyMsg = await channel.send(messageOpts); if (typeof actionConfig === "object" && actionConfig.auto_delete) { From d5363449a03475f38a14505b814f9d06cdea0a9b Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sun, 19 Dec 2021 17:47:21 +0200 Subject: [PATCH 02/15] fix: show all attachment URLs in !message, fix crash with attachments --- backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts b/backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts index 17e2c63f..9d3c6d68 100644 --- a/backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts +++ b/backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts @@ -130,9 +130,10 @@ export async function getMessageInfoEmbed( } if (message.attachments.size) { + const attachmentUrls = message.attachments.map((att) => att.url); embed.fields.push({ name: preEmbedPadding + "Attachments", - value: message.attachments[0].url, + value: attachmentUrls.join("\n"), }); } From 2b03c999be3891518ffbdbfc681c69b0b7c0d4e9 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 22 Dec 2021 15:00:53 +0200 Subject: [PATCH 03/15] feat: improve data validation errors when importing data --- backend/src/api/guilds/importExport.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/api/guilds/importExport.ts b/backend/src/api/guilds/importExport.ts index 019c5369..8d0fcfe3 100644 --- a/backend/src/api/guilds/importExport.ts +++ b/backend/src/api/guilds/importExport.ts @@ -75,7 +75,10 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) { try { data = importExportData.parse(req.body.data); } catch (err) { - return clientError(res, "Invalid import data format"); + const prettyMessage = `${err.issues[0].code}: expected ${err.issues[0].expected}, received ${ + err.issues[0].received + } at /${err.issues[0].path.join("/")}`; + return clientError(res, `Invalid import data format: ${prettyMessage}`); return; } From 264cf93fe24aa8c1e5dfab61d795cc397e1a55e9 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 22 Dec 2021 15:06:55 +0200 Subject: [PATCH 04/15] fix: fix crash when importing cases with duplicate case numbers --- backend/src/api/guilds/importExport.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/api/guilds/importExport.ts b/backend/src/api/guilds/importExport.ts index 8d0fcfe3..8bb46748 100644 --- a/backend/src/api/guilds/importExport.ts +++ b/backend/src/api/guilds/importExport.ts @@ -90,6 +90,14 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) { return; } + const seenCaseNumbers = new Set(); + for (const theCase of data.cases) { + if (seenCaseNumbers.has(theCase.case_number)) { + return clientError(res, `Duplicate case number: ${theCase.case_number}`); + } + seenCaseNumbers.add(theCase.case_number); + } + const guildCases = GuildCases.getGuildInstance(req.params.guildId); // Prepare cases From feeb0488556f10f6b02311476b32797dba314fa5 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 17 Jan 2022 21:28:00 +0200 Subject: [PATCH 05/15] debug: add debug logging to automod clean action --- backend/src/plugins/Automod/actions/clean.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Automod/actions/clean.ts b/backend/src/plugins/Automod/actions/clean.ts index 27ee1cb6..56452d79 100644 --- a/backend/src/plugins/Automod/actions/clean.ts +++ b/backend/src/plugins/Automod/actions/clean.ts @@ -4,6 +4,8 @@ import { LogType } from "../../../data/LogType"; import { noop } from "../../../utils"; import { automodAction } from "../helpers"; +const cleanDebugServer = process.env.TEMP_CLEAN_DEBUG_SERVER; + export const CleanAction = automodAction({ configType: t.boolean, defaultConfig: false, @@ -27,13 +29,26 @@ export const CleanAction = automodAction({ } } + if (pluginData.guild.id === cleanDebugServer) { + const toDeleteFormatted = Array.from(messageIdsToDeleteByChannelId.entries()) + .map(([channelId, messageIds]) => `- ${channelId}: ${messageIds.join(", ")}`) + .join("\n"); + // tslint:disable-next-line:no-console + console.log(`[DEBUG] Cleaning messages (${ruleName}):\n${toDeleteFormatted}`); + } + for (const [channelId, messageIds] of messageIdsToDeleteByChannelId.entries()) { for (const id of messageIds) { pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id); } const channel = pluginData.guild.channels.cache.get(channelId as Snowflake) as TextChannel; - await channel.bulkDelete(messageIds as Snowflake[]).catch(noop); + await channel.bulkDelete(messageIds as Snowflake[]).catch((err) => { + if (pluginData.guild.id === cleanDebugServer) { + // tslint:disable-next-line:no-console + console.error(`[DEBUG] Failed to bulk delete messages (${ruleName}): ${err}`); + } + }); } }, }); From 8c0e5aec7024c9366abfb16046d8254d22b3b93f Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Wed, 26 Jan 2022 19:51:01 -0500 Subject: [PATCH 06/15] Enable Buttons --- backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts b/backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts index a217c1e5..8ccbd01a 100644 --- a/backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts +++ b/backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts @@ -117,13 +117,13 @@ export const ReactionRolesPlugin = zeppelinGuildPlugin( RefreshReactionRolesCmd, ClearReactionRolesCmd, InitReactionRolesCmd, - // PostButtonRolesCmd, + PostButtonRolesCmd, ], // prettier-ignore events: [ AddReactionRoleEvt, - // ButtonInteractionEvt, + ButtonInteractionEvt, MessageDeletedEvt, ], configPreprocessor, From 7e29f0e95d5e354c2c7e1acc353b9268787256db Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Wed, 26 Jan 2022 19:52:02 -0500 Subject: [PATCH 07/15] Update Case Icon Emotes --- backend/src/plugins/Cases/caseIcons.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/src/plugins/Cases/caseIcons.ts b/backend/src/plugins/Cases/caseIcons.ts index 3c685804..342c25a7 100644 --- a/backend/src/plugins/Cases/caseIcons.ts +++ b/backend/src/plugins/Cases/caseIcons.ts @@ -1,13 +1,13 @@ import { CaseTypes } from "../../data/CaseTypes"; export const caseIcons: Record = { - [CaseTypes.Ban]: "<:case_ban:742540201443721317>", - [CaseTypes.Unban]: "<:case_unban:742540201670475846>", - [CaseTypes.Note]: "<:case_note:742540201368485950>", - [CaseTypes.Warn]: "<:case_warn:742540201624338454>", - [CaseTypes.Kick]: "<:case_kick:742540201661825165>", - [CaseTypes.Mute]: "<:case_mute:742540201817145364>", - [CaseTypes.Unmute]: "<:case_unmute:742540201489858643>", - [CaseTypes.Deleted]: "<:case_deleted:742540201473343529>", - [CaseTypes.Softban]: "<:case_softban:742540201766813747>", + [CaseTypes.Ban]: "<:case_ban:906897178176393246>", + [CaseTypes.Unban]: "<:case_unban:906897177824067665>", + [CaseTypes.Note]: "<:case_note:906897177832476743>", + [CaseTypes.Warn]: "<:case_warn:906897177840844832>", + [CaseTypes.Kick]: "<:case_kick:906897178310639646>", + [CaseTypes.Mute]: "<:case_mute:906897178147057664>", + [CaseTypes.Unmute]: "<:case_unmute:906897177819881523>", + [CaseTypes.Deleted]: "<:case_deleted:906897178209968148>", + [CaseTypes.Softban]: "<:case_softban:906897177828278274>", }; From 7267d6bdf354fea49f5531bb494cd53ccb5872a2 Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Wed, 26 Jan 2022 19:53:26 -0500 Subject: [PATCH 08/15] Update Success Message --- backend/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 9a37511e..24d46255 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -571,7 +571,7 @@ export function convertMSToDelayString(ms: number): string { return result; } -export function successMessage(str, emoji = "<:zep_check:650361014180904971>") { +export function successMessage(str, emoji = "<:zep_check:906897402101891093>") { return emoji ? `${emoji} ${str}` : str; } From f3f9f2248d2082b83b5ac8d861ca9624717e278a Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Wed, 26 Jan 2022 20:26:22 -0500 Subject: [PATCH 09/15] Add a custom status --- backend/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/index.ts b/backend/src/index.ts index deceb3be..3791b140 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -350,6 +350,7 @@ connect().then(async () => { client.once("ready", () => { startUptimeCounter(); +client.user?.setPresence({ activities: [{ name: "over Ibot's Lodge", type: "WATCHING" }] }); }); client.on(Constants.Events.RATE_LIMIT, (data) => { From 9d2fbee17fa75f96e8dcfa0338b5da77187ed708 Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Wed, 26 Jan 2022 20:31:35 -0500 Subject: [PATCH 10/15] Revert the last commit --- backend/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 3791b140..deceb3be 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -350,7 +350,6 @@ connect().then(async () => { client.once("ready", () => { startUptimeCounter(); -client.user?.setPresence({ activities: [{ name: "over Ibot's Lodge", type: "WATCHING" }] }); }); client.on(Constants.Events.RATE_LIMIT, (data) => { From 0f3e8f38608cd70f5f751a3d37a78e6997908706 Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:12:02 -0500 Subject: [PATCH 11/15] Re-enable Namehistory --- backend/src/data/GuildNicknameHistory.ts | 2 +- backend/src/data/UsernameHistory.ts | 2 +- backend/src/plugins/NameHistory/NameHistoryPlugin.ts | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/src/data/GuildNicknameHistory.ts b/backend/src/data/GuildNicknameHistory.ts index 9f75d24e..e0cf7cfb 100644 --- a/backend/src/data/GuildNicknameHistory.ts +++ b/backend/src/data/GuildNicknameHistory.ts @@ -17,7 +17,7 @@ if (!isAPI()) { setTimeout(cleanup, 30 * SECONDS); } -export const MAX_NICKNAME_ENTRIES_PER_USER = 10; +export const MAX_NICKNAME_ENTRIES_PER_USER = 20; export class GuildNicknameHistory extends BaseGuildRepository { private nicknameHistory: Repository; diff --git a/backend/src/data/UsernameHistory.ts b/backend/src/data/UsernameHistory.ts index 7aa4331a..bcd3ba9d 100644 --- a/backend/src/data/UsernameHistory.ts +++ b/backend/src/data/UsernameHistory.ts @@ -17,7 +17,7 @@ if (!isAPI()) { setTimeout(cleanup, 30 * SECONDS); } -export const MAX_USERNAME_ENTRIES_PER_USER = 5; +export const MAX_USERNAME_ENTRIES_PER_USER = 20; export class UsernameHistory extends BaseRepository { private usernameHistory: Repository; diff --git a/backend/src/plugins/NameHistory/NameHistoryPlugin.ts b/backend/src/plugins/NameHistory/NameHistoryPlugin.ts index 0efb5fe3..250cace5 100644 --- a/backend/src/plugins/NameHistory/NameHistoryPlugin.ts +++ b/backend/src/plugins/NameHistory/NameHistoryPlugin.ts @@ -35,9 +35,8 @@ export const NameHistoryPlugin = zeppelinGuildPlugin()({ // prettier-ignore events: [ - // FIXME: Temporary - // ChannelJoinEvt, - // MessageCreateEvt, + ChannelJoinEvt, + MessageCreateEvt, ], beforeLoad(pluginData) { From aa033dbc8f13048f8464080db1587ffbad604a75 Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:24:26 -0500 Subject: [PATCH 12/15] Update NameHistoryPlugin.ts --- backend/src/plugins/NameHistory/NameHistoryPlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/plugins/NameHistory/NameHistoryPlugin.ts b/backend/src/plugins/NameHistory/NameHistoryPlugin.ts index 250cace5..733c9306 100644 --- a/backend/src/plugins/NameHistory/NameHistoryPlugin.ts +++ b/backend/src/plugins/NameHistory/NameHistoryPlugin.ts @@ -23,7 +23,7 @@ const defaultOptions: PluginOptions = { export const NameHistoryPlugin = zeppelinGuildPlugin()({ name: "name_history", - showInDocs: false, + showInDocs: true, configSchema: ConfigSchema, defaultOptions, From 0b97577a3e54a7307519f9d69f9c3c71fea13c09 Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Sat, 19 Feb 2022 12:19:42 -0500 Subject: [PATCH 13/15] Update HelpCmd.ts --- backend/src/plugins/Utility/commands/HelpCmd.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/plugins/Utility/commands/HelpCmd.ts b/backend/src/plugins/Utility/commands/HelpCmd.ts index b03d3aa4..1f571592 100644 --- a/backend/src/plugins/Utility/commands/HelpCmd.ts +++ b/backend/src/plugins/Utility/commands/HelpCmd.ts @@ -63,7 +63,7 @@ export const HelpCmd = utilityCmd({ let snippet = `**${prefix}${trigger}**`; if (description) snippet += `\n${description}`; if (usage) snippet += `\nBasic usage: \`${usage}\``; - snippet += `\n`; + snippet += `\n`; return snippet; }); From b3a6a8672202a129108776d3cfa6d6e4a09f5574 Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:04:10 -0500 Subject: [PATCH 14/15] fix: allow 0 deleteMessageDays and fix upper limit --- backend/src/plugins/Automod/actions/ban.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/plugins/Automod/actions/ban.ts b/backend/src/plugins/Automod/actions/ban.ts index e32279a7..9cd0fd86 100644 --- a/backend/src/plugins/Automod/actions/ban.ts +++ b/backend/src/plugins/Automod/actions/ban.ts @@ -25,7 +25,7 @@ export const BanAction = automodAction({ const reason = actionConfig.reason || "Kicked automatically"; const duration = actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : undefined; const contactMethods = actionConfig.notify ? resolveActionContactMethods(pluginData, actionConfig) : undefined; - const deleteMessageDays = actionConfig.deleteMessageDays || undefined; + const deleteMessageDays = actionConfig.deleteMessageDays ?? undefined; const caseArgs: Partial = { modId: pluginData.client.user!.id, From 7b75102f8e90ed7c8e8eead338225195688123b2 Mon Sep 17 00:00:00 2001 From: Ibotmealot <42391199+Ibotmealot@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:04:58 -0500 Subject: [PATCH 15/15] fix: allow 0 deleteMessageDays and fix upper limit --- backend/src/plugins/ModActions/functions/banUserId.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/plugins/ModActions/functions/banUserId.ts b/backend/src/plugins/ModActions/functions/banUserId.ts index 21d02738..9833ce2c 100644 --- a/backend/src/plugins/ModActions/functions/banUserId.ts +++ b/backend/src/plugins/ModActions/functions/banUserId.ts @@ -85,7 +85,7 @@ export async function banUserId( pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, userId); ignoreEvent(pluginData, IgnoredEventType.Ban, userId); try { - const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1)); + const deleteMessageDays = Math.min(7, Math.max(0, banOptions.deleteMessageDays ?? 1)); await pluginData.guild.bans.create(userId as Snowflake, { days: deleteMessageDays, reason: reason ?? undefined,