From a4e7b5624f57093c30be12b8eecf58c0d7a81ffd Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Fri, 7 May 2021 18:27:19 +0200 Subject: [PATCH] Trim down reason to <512 characters as to not receive api errors --- backend/src/plugins/ModActions/functions/banUserId.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/plugins/ModActions/functions/banUserId.ts b/backend/src/plugins/ModActions/functions/banUserId.ts index 0fc69371..3a2679f6 100644 --- a/backend/src/plugins/ModActions/functions/banUserId.ts +++ b/backend/src/plugins/ModActions/functions/banUserId.ts @@ -85,6 +85,10 @@ export async function banUserId( ignoreEvent(pluginData, IgnoredEventType.Ban, userId); try { const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1)); + // Trim down reason to 490 words, API limit is 512 and we leave a gap to accomodate cross-ban bots + if (reason && reason.length >= 490) { + reason = reason.substring(0, 200) + "..."; + } await pluginData.guild.bans.create(userId as Snowflake, { days: deleteMessageDays, reason: reason ?? undefined,