Allow external VoiceChannel client API implementation (#1057)

* ConnectAsync(bool external) API implemented

This allows developers to handle the AudioClient externally (for example with Lavalink)

* Modify ConnectAsync API and add DisconnectAsync to IAudioChannel

* Update summary message on IAudioChannel.DisconnectAsync()

* Review changes:
- Fix `if (!external)` styling
- Remove unecessary ConnectAsync overload

* SocketVoiceChannel overload update

* Update IAudioChannel.ConnectAsync()
- Remove ConfigAction from parameters
- Add SelfDeafen/SelfMute to parameters

* Remove SocketVoiceChannel.ConnectAsync() default params (Inherit)
This commit is contained in:
NovusTheory
2018-05-31 16:21:57 -05:00
committed by Finite Reality
parent 3acf2a9a6b
commit 890904f32c
6 changed files with 32 additions and 15 deletions

View File

@@ -211,7 +211,8 @@ namespace Discord.WebSocket
=> EnterTypingState(options);
//IAudioChannel
Task<IAudioClient> IAudioChannel.ConnectAsync(Action<IAudioClient> configAction) { throw new NotSupportedException(); }
Task<IAudioClient> IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external) { throw new NotSupportedException(); }
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
//IChannel
Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)

View File

@@ -43,11 +43,14 @@ namespace Discord.WebSocket
public Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null)
=> ChannelHelper.ModifyAsync(this, Discord, func, options);
public async Task<IAudioClient> ConnectAsync(Action<IAudioClient> configAction = null)
public async Task<IAudioClient> ConnectAsync(bool selfDeaf, bool selfMute, bool external)
{
return await Guild.ConnectAudioAsync(Id, false, false, configAction).ConfigureAwait(false);
return await Guild.ConnectAudioAsync(Id, selfDeaf, selfMute, external).ConfigureAwait(false);
}
public async Task DisconnectAsync()
=> await Guild.DisconnectAudioAsync();
public override SocketGuildUser GetUser(ulong id)
{
var user = Guild.GetUser(id);