private async Task OnDisconnected(Exception exception) { if (Configuration.PreservePlayers) { return; } foreach (var player in Players.Values) { await player.DisposeAsync().ConfigureAwait(false); } Players.Clear(); ShadowLog?.WriteLog(LogSeverity.Error, "WebSocket disconnected! Disposing all connected players.", exception); }
private async Task OnShardDisconnected(Exception exception, DiscordSocketClient socketClient) { if (Configuration.PreservePlayers) { return; } foreach (var guild in socketClient.Guilds) { if (!Players.TryRemove(guild.Id, out var player)) { continue; } await player.DisposeAsync().ConfigureAwait(false); } Players.Clear(); ShadowLog?.WriteLog(LogSeverity.Error, "Shards disconnecting. Disposing all connected players.", exception); }