From 047ab872df05f986564f6e465f9cc7deca65ca27 Mon Sep 17 00:00:00 2001 From: Almeida Date: Wed, 27 Dec 2023 18:44:35 +0000 Subject: [PATCH] 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 659be65b1..bb6c06fec 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())