From 703dc7b3b2e0fcc79f2d5dc2783a5eb5652a5083 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 3 Jan 2017 22:49:39 +0100 Subject: [PATCH] More attempts to stabilize --- src/NadekoBot/ShardedDiscordClient.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/ShardedDiscordClient.cs b/src/NadekoBot/ShardedDiscordClient.cs index 8a341197..2c6037b0 100644 --- a/src/NadekoBot/ShardedDiscordClient.cs +++ b/src/NadekoBot/ShardedDiscordClient.cs @@ -65,6 +65,13 @@ namespace NadekoBot client.ChannelUpdated += (arg1, arg2) => { ChannelUpdated(arg1, arg2); return Task.CompletedTask; }; _log.Info($"Shard #{i} initialized."); + + client.Disconnected += (ex) => + { + _log.Error("Shard #{0} disconnected", i); + _log.Error(ex); + return Task.CompletedTask; + }; } Clients = clientList.AsReadOnly(); @@ -85,8 +92,14 @@ namespace NadekoBot public Task GetDMChannelAsync(ulong channelId) => Clients[0].GetDMChannelAsync(channelId); - internal Task LoginAsync(TokenType tokenType, string token) => - Task.WhenAll(Clients.Select(async c => { await c.LoginAsync(tokenType, token).ConfigureAwait(false); _log.Info($"Shard #{c.ShardId} logged in."); })); + internal async Task LoginAsync(TokenType tokenType, string token) + { + foreach (var c in Clients) + { + await c.LoginAsync(tokenType, token).ConfigureAwait(false); + _log.Info($"Shard #{c.ShardId} logged in."); + } + } internal async Task ConnectAsync() {