diff --git a/Bot/Discord/Dc.cs b/Bot/Discord/Dc.cs index 87a6f6b..4ad6c12 100644 --- a/Bot/Discord/Dc.cs +++ b/Bot/Discord/Dc.cs @@ -36,9 +36,12 @@ private static Task Log(LogMessage msg) return Task.CompletedTask; } + private static uint readyCount; private static async Task Ready() { + readyCount++; s_botLog = (SocketTextChannel)s_bot.GetChannel(Secrets.s_botLogId); + await s_botLog.SendMessageAsync($"Ready {readyCount}"); _ = Task.Run(EventBotReady); await s_interactionSvc.RegisterCommandsGloballyAsync(); } @@ -123,7 +126,21 @@ internal static async Task ExceptionAsync(Exception ex) Name = exName }; } - await s_botLog.SendMessageAsync(s_botApp.Owner.Mention, embed: emb.Build()); + + // Always waits until the exception is actually sent + while (true) + { + try + { + await s_botLog.SendMessageAsync(s_botApp.Owner.Mention, embed: emb.Build()); + return; + } + catch (Exception) + { + // ignored + } + } + } internal static async Task SendLogAsync(string msg) => await s_botLog.SendMessageAsync(msg);