diff --git a/src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs b/src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs
index 0f97c62d5..ebcb5769e 100644
--- a/src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs
@@ -7,9 +7,6 @@ namespace Discord
public interface IAudioChannel : IChannel
{
/// Connects to this audio channel.
- Task ConnectAsync(Action configAction = null);
-
- /// Connects to this audio channel but can specify if client is handled externally.
Task ConnectAsync(Action configAction = null, bool external = false);
/// Disconnects from this audio channel.
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
index ec03fd8ee..4564ce4bc 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
@@ -143,7 +143,6 @@ namespace Discord.Rest
=> EnterTypingState(options);
//IAudioChannel
- Task IAudioChannel.ConnectAsync(Action configAction) { throw new NotSupportedException(); }
Task IAudioChannel.ConnectAsync(Action configAction, bool external) { throw new NotSupportedException(); }
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
index f751a7932..85d05127a 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
@@ -41,7 +41,6 @@ namespace Discord.Rest
private string DebuggerDisplay => $"{Name} ({Id}, Voice)";
//IAudioChannel
- Task IAudioChannel.ConnectAsync(Action configAction) { throw new NotSupportedException(); }
Task IAudioChannel.ConnectAsync(Action configAction, bool external) { throw new NotSupportedException(); }
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
index 315dceb7e..bd15e8955 100644
--- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
+++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
@@ -206,7 +206,6 @@ namespace Discord.WebSocket
=> EnterTypingState(options);
//IAudioChannel
- Task IAudioChannel.ConnectAsync(Action configAction) { throw new NotSupportedException(); }
Task IAudioChannel.ConnectAsync(Action configAction, bool external) { throw new NotSupportedException(); }
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
index 8ff8e71e7..5aec0a1f4 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
@@ -518,37 +518,38 @@ namespace Discord.WebSocket
promise = new TaskCompletionSource();
_audioConnectPromise = promise;
- if (!external)
+ if (external)
{
- if (_audioClient == null)
+ var _ = promise.TrySetResultAsync(null);
+ await Discord.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false);
+ return null;
+ }
+
+ if (_audioClient == null)
+ {
+ var audioClient = new AudioClient(this, Discord.GetAudioId(), channelId);
+ audioClient.Disconnected += async ex =>
{
- var audioClient = new AudioClient(this, Discord.GetAudioId(), channelId);
- audioClient.Disconnected += async ex =>
- {
- if (!promise.Task.IsCompleted)
- {
- try
- { audioClient.Dispose(); }
- catch { }
- _audioClient = null;
- if (ex != null)
- await promise.TrySetExceptionAsync(ex);
- else
- await promise.TrySetCanceledAsync();
- return;
- }
- };
- audioClient.Connected += () =>
+ if (!promise.Task.IsCompleted)
{
- var _ = promise.TrySetResultAsync(_audioClient);
- return Task.Delay(0);
- };
- configAction?.Invoke(audioClient);
- _audioClient = audioClient;
- }
- } else
- {
- var _ = promise.TrySetResultAsync(null);
+ try
+ { audioClient.Dispose(); }
+ catch { }
+ _audioClient = null;
+ if (ex != null)
+ await promise.TrySetExceptionAsync(ex);
+ else
+ await promise.TrySetCanceledAsync();
+ return;
+ }
+ };
+ audioClient.Connected += () =>
+ {
+ var _ = promise.TrySetResultAsync(_audioClient);
+ return Task.Delay(0);
+ };
+ configAction?.Invoke(audioClient);
+ _audioClient = audioClient;
}
await Discord.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false);