Use async methods and feed exceptions to promise

This commit is contained in:
Finite Reality
2016-07-31 18:53:04 +01:00
parent 1d5ae33e0e
commit c3dc8cd15a

View File

@@ -307,8 +307,16 @@ namespace Discord
{ {
_audioLock.Release(); _audioLock.Release();
} }
await audioClient.ConnectAsync(url, CurrentUser.Id, voiceState.VoiceSessionId, token).ConfigureAwait(false);
_audioConnectPromise.TrySetResult(true); try
{
await audioClient.ConnectAsync(url, CurrentUser.Id, voiceState.VoiceSessionId, token).ConfigureAwait(false);
await _audioConnectPromise.TrySetResultAsync(true).ConfigureAwait(false);
}
catch(Exception e)
{
await _audioConnectPromise.SetExceptionAsync(e).ConfigureAwait(false);
}
} }
public SocketGuild Clone() => MemberwiseClone() as SocketGuild; public SocketGuild Clone() => MemberwiseClone() as SocketGuild;