From 8cf50a7d9726d5a215280add59da3d859e9a0ad1 Mon Sep 17 00:00:00 2001 From: Iris System Date: Mon, 2 Oct 2023 10:48:13 +1300 Subject: [PATCH] fix(bot): remove query params from image attachment URLs for now Discord is adding authentication parameters to CDN URLs - these being present in stored URLs breaks when they expire, but CDN URLs still work without those parameters until November/December 2023 --- PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs index 3d36529a..825443da 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs @@ -33,8 +33,11 @@ public static class ContextAvatarExt // If we have an attachment, use that if (ctx.Message.Attachments.FirstOrDefault() is { } attachment) { - var url = attachment.ProxyUrl; - return new ParsedImage { Url = url, Source = AvatarSource.Attachment }; + // XXX: strip query params from attachment URLs because of new Discord CDN shenanigans + var uriBuilder = new UriBuilder(attachment.ProxyUrl); + uriBuilder.Query = ""; + + return new ParsedImage { Url = uriBuilder.Uri.AbsoluteUri, Source = AvatarSource.Attachment }; } // We should only get here if there are no arguments (which would get parsed as URL + throw if error)