From d47e7e7a068f3e44a6c5c242c55647fb03e623e4 Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 15 Jul 2019 21:29:45 +0200 Subject: [PATCH] Don't process messages until we're fully connected to shard zero --- PluralKit.Bot/Bot.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PluralKit.Bot/Bot.cs b/PluralKit.Bot/Bot.cs index 89c42926..16d2ffcd 100644 --- a/PluralKit.Bot/Bot.cs +++ b/PluralKit.Bot/Bot.cs @@ -171,6 +171,11 @@ namespace PluralKit.Bot private async Task MessageReceived(SocketMessage _arg) { + // _client.CurrentUser will be null if we've connected *some* shards but not shard #0 yet + // This will cause an error in WebhookCacheServices so we just workaround and don't process any messages + // until we properly connect. TODO: can we do this without chucking away a bunch of messages? + if (_client.CurrentUser == null) return; + using (SentrySdk.PushScope()) using (var serviceScope = _services.CreateScope()) {