From e0ed5b528eebf2142630a35dfa90d74d07d72120 Mon Sep 17 00:00:00 2001 From: spiral Date: Thu, 31 Mar 2022 07:23:31 -0400 Subject: [PATCH] fix: get thread parent from API instead of cache for cross-cluster message edit --- PluralKit.Bot/Services/WebhookExecutorService.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PluralKit.Bot/Services/WebhookExecutorService.cs b/PluralKit.Bot/Services/WebhookExecutorService.cs index b816d6f9..c9596545 100644 --- a/PluralKit.Bot/Services/WebhookExecutorService.cs +++ b/PluralKit.Bot/Services/WebhookExecutorService.cs @@ -86,11 +86,14 @@ public class WebhookExecutorService }; ulong? threadId = null; - var root = await _cache.GetRootChannel(channelId); - if (root.Id != channelId) + var channel = await _cache.GetOrFetchChannel(_rest, channelId); + if (channel.IsThread()) + { threadId = channelId; + channelId = channel.ParentId.Value; + } - var webhook = await _webhookCache.GetWebhook(root.Id); + var webhook = await _webhookCache.GetWebhook(channelId); return await _rest.EditWebhookMessage(webhook.Id, webhook.Token, messageId, new WebhookMessageEditRequest { Content = newContent, AllowedMentions = allowedMentions },