From dec5690023a52eadb81dc96b2241c42f5849019c Mon Sep 17 00:00:00 2001 From: Death Date: Thu, 18 Jun 2020 10:49:44 +0200 Subject: [PATCH] actually wait for bot to be connected before querying guild info --- CHEF/CHEF.cs | 13 ++++++++----- CHEF/Logger.cs | 7 +------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHEF/CHEF.cs b/CHEF/CHEF.cs index df11451..3ac03aa 100644 --- a/CHEF/CHEF.cs +++ b/CHEF/CHEF.cs @@ -15,14 +15,17 @@ public static void Main(string[] args) private async Task MainAsync() { - SetupBotLogin().Wait(); - - Logger.Init(_client); - - Database.Init(); + await SetupBotLogin(); await ComponentHandler.Init(_client); + _client.Ready += () => + { + Logger.Init(_client); + Database.Init(); + return Task.CompletedTask; + }; + await Task.Delay(-1); } diff --git a/CHEF/Logger.cs b/CHEF/Logger.cs index 21b3abf..9d97468 100644 --- a/CHEF/Logger.cs +++ b/CHEF/Logger.cs @@ -21,16 +21,11 @@ internal static void Init(DiscordSocketClient client) _client = client; var guild = client.GetGuild(ror2ServerId); - if (guild == null) - { - Console.WriteLine("guild was null"); - } - else + if (guild != null) { _reportToUser = guild.GetUser(iDeathHdId); if (_reportToUser == null) { - Console.WriteLine("_reportToUser was null"); _reportToUser = _client.Rest.GetGuildUserAsync(ror2ServerId, iDeathHdId).Result; } }