if (_client.ConnectionState == ConnectionState.Disconnected)
{
Console.WriteLine($"{DateTime.Now} -> Disconnected status detected - running new Task, to check is bot still working properly!");
Task.Run(async () =>
{
await Task.Delay(10 * 1000);
if (_client.ConnectionState == ConnectionState.Disconnected)
{
Console.WriteLine($"{DateTime.Now} -> Process is killing itself, due to Disconnected status has not changed, after 10 seconds delay.");
Process.GetCurrentProcess().Kill();
}
else
{
Console.WriteLine($"{DateTime.Now} -> OK! Bot is still working.");
}
});
}