Browse Source

Use async methods and feed exceptions to promise

tags/1.0-rc
Finite Reality 8 years ago
parent
commit
c3dc8cd15a
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      src/Discord.Net/WebSocket/Entities/Guilds/SocketGuild.cs

+ 10
- 2
src/Discord.Net/WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -307,8 +307,16 @@ namespace Discord
{
_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;


Loading…
Cancel
Save