Skip to content

Commit 4b977f9

Browse files
13xforeverclienthax
authored andcommitted
actually maybe it's enough to do the usual manual reconnect
1 parent 204328f commit 4b977f9

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

CompatBot/Watchdog.cs

+2-20
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ public static async Task Watch(DiscordClient client)
2626
do
2727
{
2828
await Task.Delay(Config.SocketDisconnectCheckIntervalInSec, Config.Cts.Token).ConfigureAwait(false);
29-
foreach (var sudoer in ModProvider.Mods.Values.Where(m => m.Sudoer))
30-
{
31-
var user = await client.GetUserAsync(sudoer.DiscordId).ConfigureAwait(false);
32-
if (user?.Presence?.Activity?.CustomStatus?.Name is string cmd && cmd.StartsWith("restart"))
33-
{
34-
var instance = cmd.Split(' ', StringSplitOptions.RemoveEmptyEntries).LastOrDefault();
35-
if (ulong.TryParse(instance, out var botId) && botId == client.CurrentUser.Id)
36-
{
37-
Config.Log.Warn($"Found request to restart on {user.Username}#{user.Discriminator}'s custom status");
38-
Sudo.Bot.Restart(Program.InvalidChannelId, $"Restarted by request from {user.Username}#{user.Discriminator}'s custom status");
39-
}
40-
}
41-
}
42-
4329
if (IsOk)
4430
continue;
4531

@@ -89,12 +75,8 @@ public static void OnLogHandler(string level, string message)
8975
}
9076
else if (level == nameof(LogLevel.Fatal))
9177
{
92-
if (message.Contains("Connection closed (-1, '')"))
93-
{
94-
Config.Log.Warn("Potential dangling socket, restarting…");
95-
Sudo.Bot.Restart(Program.InvalidChannelId, $@"Restarted to reset potential dangling socket");
96-
}
97-
if (message.Contains("Socket connection terminated")
78+
if (message.Contains("Connection closed (-1, '')")
79+
|| message.Contains("Socket connection terminated")
9880
|| message.Contains("heartbeats were skipped. Issuing reconnect."))
9981
DisconnectTimestamps.Enqueue(DateTime.UtcNow);
10082
}

0 commit comments

Comments
 (0)