diff --git a/src/NadekoBot/DataStructures/ShardCom/IShardComMessage.cs b/src/NadekoBot/DataStructures/ShardCom/IShardComMessage.cs index 9fb1f5d0..6f54df59 100644 --- a/src/NadekoBot/DataStructures/ShardCom/IShardComMessage.cs +++ b/src/NadekoBot/DataStructures/ShardCom/IShardComMessage.cs @@ -12,5 +12,6 @@ namespace NadekoBot.DataStructures.ShardCom public int ShardId { get; set; } public ConnectionState ConnectionState { get; set; } public int Guilds { get; set; } + public DateTime Time { get; set; } } } diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index d8bc759d..a5d4fc26 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -270,7 +270,7 @@ namespace NadekoBot.Modules.Music add += Format.Bold(GetText("queue_stopped", Format.Code(Prefix + "play"))) + "\n"; var mps = mp.MaxPlaytimeSeconds; if (mps > 0) - add += Format.Bold(GetText("song_skips_after", TimeSpan.FromSeconds(mps).ToString("g"))) + "\n"; + add += Format.Bold(GetText("song_skips_after", TimeSpan.FromSeconds(mps).ToString("HH\\:mm\\:ss"))) + "\n"; if (mp.RepeatCurrentSong) add += "🔂 " + GetText("repeating_cur_song") + "\n"; else if (mp.Shuffle) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 7a6f9ae1..02d93d2c 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -295,8 +295,13 @@ namespace NadekoBot.Modules.Utility var allShardStrings = statuses .Select(x => - GetText("shard_stats_txt", x.ShardId.ToString(), - Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.ToString()))) + { + var timeDiff = DateTime.UtcNow - x.Time; + if (timeDiff > TimeSpan.FromSeconds(20)) + return $"Shard #{x.ShardId.ToString()} **UNRESPONSIVE** for {timeDiff.ToString(@"hh\:mm\:ss")}"; + return GetText("shard_stats_txt", x.ShardId.ToString(), + Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.ToString()), timeDiff.ToString(@"hh\:mm\:ss")); + }) .ToArray(); await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) => diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 82c384bc..1661511c 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -130,8 +130,9 @@ namespace NadekoBot ConnectionState = Client.ConnectionState, Guilds = Client.ConnectionState == ConnectionState.Connected ? Client.Guilds.Count : 0, ShardId = Client.ShardId, + Time = DateTime.UtcNow, }); - await Task.Delay(1000); + await Task.Delay(5000); } }); } diff --git a/src/NadekoBot/ShardsCoordinator.cs b/src/NadekoBot/ShardsCoordinator.cs index 18725566..1516f868 100644 --- a/src/NadekoBot/ShardsCoordinator.cs +++ b/src/NadekoBot/ShardsCoordinator.cs @@ -3,6 +3,7 @@ using NadekoBot.Services; using NadekoBot.Services.Impl; using NLog; using System; +using System.Collections.Concurrent; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; @@ -21,7 +22,7 @@ namespace NadekoBot private readonly Logger _log; private readonly ShardComServer _comServer; private readonly int _port; - + public ShardsCoordinator(int port) { LogSetup.SetupLogger(); @@ -40,6 +41,7 @@ namespace NadekoBot private Task _comServer_OnDataReceived(ShardComMessage msg) { Statuses[msg.ShardId] = msg; + if (msg.ConnectionState == Discord.ConnectionState.Disconnected || msg.ConnectionState == Discord.ConnectionState.Disconnecting) _log.Error("!!! SHARD {0} IS IN {1} STATE", msg.ShardId, msg.ConnectionState.ToString()); return Task.CompletedTask; @@ -87,7 +89,7 @@ namespace NadekoBot _log.Info(string.Join("\n", Statuses .ToArray() .Where(x => x != null) - .Select(x => $"Shard {x.ShardId} is in {x.ConnectionState.ToString()} state with {x.Guilds} servers")) + "\n" + groupStr); + .Select(x => $"Shard {x.ShardId} is in {x.ConnectionState.ToString()} state with {x.Guilds} servers. {(DateTime.UtcNow - x.Time).ToString(@"hh\:mm\:ss")} ago")) + "\n" + groupStr); break; default: break; diff --git a/src/NadekoBot/_strings/ResponseStrings.en-US.json b/src/NadekoBot/_strings/ResponseStrings.en-US.json index fa4bea1a..06d62f39 100644 --- a/src/NadekoBot/_strings/ResponseStrings.en-US.json +++ b/src/NadekoBot/_strings/ResponseStrings.en-US.json @@ -678,7 +678,7 @@ "utility_server_info": "Server info", "utility_shard": "Shard", "utility_shard_stats": "Shard stats", - "utility_shard_stats_txt": "Shard **#{0}** is in {1} state with {2} servers", + "utility_shard_stats_txt": "Shard **#{0}** is in {1} state with {2} servers - {3} ago", "utility_showemojis": "**Name:** {0} **Link:** {1}", "utility_showemojis_none": "No special emojis found.", "utility_stats_songs": "Playing {0} songs, {1} queued.",