Dont crash if client is disconnected from within DiscordClient.Run
This commit is contained in:
@@ -257,7 +257,11 @@ namespace Discord
|
||||
/// <summary> Blocking call that will not return until client has been stopped. This is mainly intended for use in console applications. </summary>
|
||||
public void Run(Func<Task> asyncAction)
|
||||
{
|
||||
asyncAction().Wait();
|
||||
try
|
||||
{
|
||||
asyncAction().Wait();
|
||||
}
|
||||
catch (AggregateException ex) when (ex.InnerException is TaskCanceledException) { }
|
||||
_disconnectedEvent.WaitOne();
|
||||
}
|
||||
/// <summary> Blocking call that will not return until client has been stopped. This is mainly intended for use in console applications. </summary>
|
||||
|
||||
Reference in New Issue
Block a user