From 838da3d8275397c26d436ac61bf8bb231c9ff4c5 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sat, 17 Jun 2017 14:51:09 +0200 Subject: [PATCH] Connecting will now show how many shards connected so far --- src/NadekoBot/NadekoBot.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index cce74a53..44802af6 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -249,14 +249,12 @@ namespace NadekoBot await Client.LoginAsync(TokenType.Bot, token).ConfigureAwait(false); await Client.StartAsync().ConfigureAwait(false); - // wait for all shards to be ready - int readyCount = 0; - foreach (var s in Client.Shards) - s.Ready += () => Task.FromResult(Interlocked.Increment(ref readyCount)); - _log.Info("Waiting for all shards to connect..."); - while (readyCount < Client.Shards.Count) - await Task.Delay(100).ConfigureAwait(false); + while (!Client.Shards.All(x => x.ConnectionState == ConnectionState.Connected)) + { + _log.Info("Connecting... {0}/{1}", Client.Shards.Count(x => x.ConnectionState == ConnectionState.Connected), Client.Shards.Count); + await Task.Delay(1000).ConfigureAwait(false); + } } public async Task RunAsync(params string[] args)