Browse Source

Expose SendVoiceStateUpdateAsync API to clients

Fixes #1882
pull/1888/head
Pawel Panek 4 years ago
parent
commit
1a11cae732
8 changed files with 32 additions and 0 deletions
  1. +8
    -0
      src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs
  2. +1
    -0
      src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
  3. +1
    -0
      src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
  4. +1
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
  5. +5
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs
  6. +6
    -0
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
  7. +5
    -0
      test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs
  8. +5
    -0
      test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs

+ 8
- 0
src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs View File

@@ -27,5 +27,13 @@ namespace Discord
/// A task representing the asynchronous operation for disconnecting from the audio channel.
/// </returns>
Task DisconnectAsync();

/// <summary>
/// Sends voice state update of this audio channel.
/// </summary>
/// <param name="selfDeaf">Determines whether the client should deaf itself.</param>
/// <param name="selfMute">Determines whether the client should mute itself.</param>
/// <returns></returns>
Task SendVoiceStateUpdateAsync(bool selfDeaf, bool selfMute);
}
}

+ 1
- 0
src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs View File

@@ -196,6 +196,7 @@ namespace Discord.Rest
/// <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 IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
Task IAudioChannel.SendVoiceStateUpdateAsync(bool selfDeaf, bool selfMute) { throw new NotSupportedException(); }

//IChannel
Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)


+ 1
- 0
src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs View File

@@ -76,6 +76,7 @@ namespace Discord.Rest
/// <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 IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
Task IAudioChannel.SendVoiceStateUpdateAsync(bool selfDeaf, bool selfMute) { throw new NotSupportedException(); }

//IGuildChannel
/// <inheritdoc />


+ 1
- 0
src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs View File

@@ -311,6 +311,7 @@ namespace Discord.WebSocket
/// <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 IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
Task IAudioChannel.SendVoiceStateUpdateAsync(bool selfDeaf, bool selfMute) { throw new NotSupportedException(); }

//IChannel
/// <inheritdoc />


+ 5
- 0
src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs View File

@@ -76,6 +76,11 @@ namespace Discord.WebSocket
public async Task DisconnectAsync()
=> await Guild.DisconnectAudioAsync();

public async Task SendVoiceStateUpdateAsync(bool selfDeaf, bool selfMute)
{
await Guild.SendVoiceStateUpdateAsync(Id, selfDeaf, selfMute);
}

/// <inheritdoc />
public override SocketGuildUser GetUser(ulong id)
{


+ 6
- 0
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -1131,6 +1131,12 @@ namespace Discord.WebSocket
_audioLock.Release();
}
}

internal async Task SendVoiceStateUpdateAsync(ulong channelId, bool selfDeaf, bool selfMute)
{
await Discord.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false);
}

private async Task DisconnectAudioInternalAsync()
{
_audioConnectPromise?.TrySetCanceledAsync(); //Cancel any previous audio connection


+ 5
- 0
test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs View File

@@ -41,6 +41,11 @@ namespace Discord
throw new NotImplementedException();
}

public Task SendVoiceStateUpdateAsync(bool selfDeaf, bool selfMute)
{
throw new NotImplementedException();
}

public IDisposable EnterTypingState(RequestOptions options = null)
{
throw new NotImplementedException();


+ 5
- 0
test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs View File

@@ -58,6 +58,11 @@ namespace Discord
throw new NotImplementedException();
}

public Task SendVoiceStateUpdateAsync(bool selfDeaf, bool selfMute)
{
throw new NotImplementedException();
}

public Task<ICategoryChannel> GetCategoryAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null)
{
throw new NotImplementedException();


Loading…
Cancel
Save