[Feature] Allow switching voice channels without disconnecting (external clients only) (#2866)
* eh well it should work * fix issues * make sure an external client is used
This commit is contained in:
@@ -23,11 +23,12 @@ namespace Discord
|
|||||||
/// <param name="selfDeaf">Determines whether the client should deaf itself upon connection.</param>
|
/// <param name="selfDeaf">Determines whether the client should deaf itself upon connection.</param>
|
||||||
/// <param name="selfMute">Determines whether the client should mute itself upon connection.</param>
|
/// <param name="selfMute">Determines whether the client should mute itself upon connection.</param>
|
||||||
/// <param name="external">Determines whether the audio client is an external one or not.</param>
|
/// <param name="external">Determines whether the audio client is an external one or not.</param>
|
||||||
|
/// <param name="disconnect">Determines whether the client should send a disconnect call before sending the new voice state.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A task representing the asynchronous connection operation. The task result contains the
|
/// A task representing the asynchronous connection operation. The task result contains the
|
||||||
/// <see cref="IAudioClient"/> responsible for the connection.
|
/// <see cref="IAudioClient"/> responsible for the connection.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false);
|
Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false, bool disconnect = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disconnects from this audio channel.
|
/// Disconnects from this audio channel.
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ namespace Discord.Rest
|
|||||||
#region IAudioChannel
|
#region IAudioChannel
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <exception cref="NotSupportedException">Connecting to a group channel is not supported.</exception>
|
/// <exception cref="NotSupportedException">Connecting to a group channel is not supported.</exception>
|
||||||
Task<IAudioClient> IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external) { throw new NotSupportedException(); }
|
Task<IAudioClient> IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external, bool disconnect) { throw new NotSupportedException(); }
|
||||||
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
|
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
|
||||||
Task IAudioChannel.ModifyAsync(Action<AudioChannelProperties> func, RequestOptions options) { throw new NotSupportedException(); }
|
Task IAudioChannel.ModifyAsync(Action<AudioChannelProperties> func, RequestOptions options) { throw new NotSupportedException(); }
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace Discord.Rest
|
|||||||
#region IAudioChannel
|
#region IAudioChannel
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <exception cref="NotSupportedException">Connecting to a REST-based channel is not supported.</exception>
|
/// <exception cref="NotSupportedException">Connecting to a REST-based channel is not supported.</exception>
|
||||||
Task<IAudioClient> IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external) { throw new NotSupportedException(); }
|
Task<IAudioClient> IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external, bool disconnect) { throw new NotSupportedException(); }
|
||||||
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
|
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
|
||||||
Task IAudioChannel.ModifyAsync(Action<AudioChannelProperties> func, RequestOptions options) { throw new NotSupportedException(); }
|
Task IAudioChannel.ModifyAsync(Action<AudioChannelProperties> func, RequestOptions options) { throw new NotSupportedException(); }
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ namespace Discord.WebSocket
|
|||||||
#region IAudioChannel
|
#region IAudioChannel
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <exception cref="NotSupportedException">Connecting to a group channel is not supported.</exception>
|
/// <exception cref="NotSupportedException">Connecting to a group channel is not supported.</exception>
|
||||||
Task<IAudioClient> IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external) { throw new NotSupportedException(); }
|
Task<IAudioClient> IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external, bool disconnect) { throw new NotSupportedException(); }
|
||||||
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
|
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
|
||||||
Task IAudioChannel.ModifyAsync(Action<AudioChannelProperties> func, RequestOptions options) { throw new NotSupportedException(); }
|
Task IAudioChannel.ModifyAsync(Action<AudioChannelProperties> func, RequestOptions options) { throw new NotSupportedException(); }
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ namespace Discord.WebSocket
|
|||||||
=> ChannelHelper.ModifyAsync(this, Discord, func, options);
|
=> ChannelHelper.ModifyAsync(this, Discord, func, options);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false)
|
public Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false, bool disconnect = true)
|
||||||
=> Guild.ConnectAudioAsync(Id, selfDeaf, selfMute, external);
|
=> Guild.ConnectAudioAsync(Id, selfDeaf, selfMute, external, disconnect);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task DisconnectAsync()
|
public Task DisconnectAsync()
|
||||||
|
|||||||
@@ -1723,13 +1723,14 @@ namespace Discord.WebSocket
|
|||||||
{
|
{
|
||||||
return _audioClient?.GetInputStream(userId);
|
return _audioClient?.GetInputStream(userId);
|
||||||
}
|
}
|
||||||
internal async Task<IAudioClient> ConnectAudioAsync(ulong channelId, bool selfDeaf, bool selfMute, bool external)
|
internal async Task<IAudioClient> ConnectAudioAsync(ulong channelId, bool selfDeaf, bool selfMute, bool external, bool disconnect = true)
|
||||||
{
|
{
|
||||||
TaskCompletionSource<AudioClient> promise;
|
TaskCompletionSource<AudioClient> promise;
|
||||||
|
|
||||||
await _audioLock.WaitAsync().ConfigureAwait(false);
|
await _audioLock.WaitAsync().ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (disconnect || !external)
|
||||||
await DisconnectAudioInternalAsync().ConfigureAwait(false);
|
await DisconnectAudioInternalAsync().ConfigureAwait(false);
|
||||||
promise = new TaskCompletionSource<AudioClient>();
|
promise = new TaskCompletionSource<AudioClient>();
|
||||||
_audioConnectPromise = promise;
|
_audioConnectPromise = promise;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Discord
|
|||||||
|
|
||||||
public string RTCRegion => throw new NotImplementedException();
|
public string RTCRegion => throw new NotImplementedException();
|
||||||
|
|
||||||
public Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false)
|
public Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false, bool disconnect = true)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Discord
|
|||||||
|
|
||||||
public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null) => throw new NotImplementedException();
|
public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null) => throw new NotImplementedException();
|
||||||
public Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null) => throw new NotImplementedException();
|
public Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null) => throw new NotImplementedException();
|
||||||
public Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false) => throw new NotImplementedException();
|
public Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false, bool disconnect = true) => throw new NotImplementedException();
|
||||||
public Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => throw new NotImplementedException();
|
public Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => throw new NotImplementedException();
|
||||||
public Task<IInviteMetadata> CreateInviteToApplicationAsync(ulong applicationId, int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => throw new NotImplementedException();
|
public Task<IInviteMetadata> CreateInviteToApplicationAsync(ulong applicationId, int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => throw new NotImplementedException();
|
||||||
public Task<IInviteMetadata> CreateInviteToApplicationAsync(DefaultApplications application, int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => throw new NotImplementedException();
|
public Task<IInviteMetadata> CreateInviteToApplicationAsync(DefaultApplications application, int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => throw new NotImplementedException();
|
||||||
|
|||||||
Reference in New Issue
Block a user