Browse Source

Add RTCRegion to voice channels (#2002)

* Add RTCRegion to voice channels

* Update MockedGroupChannel.cs
tags/3.1.0
Quin Lynch GitHub 3 years ago
parent
commit
2a416a355c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 0 deletions
  1. +8
    -0
      src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs
  2. +2
    -0
      src/Discord.Net.Rest/API/Common/Channel.cs
  3. +4
    -0
      src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
  4. +4
    -0
      src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
  5. +5
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
  6. +3
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs
  7. +2
    -0
      test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs
  8. +2
    -0
      test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs

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

@@ -9,6 +9,14 @@ namespace Discord
/// </summary>
public interface IAudioChannel : IChannel
{
/// <summary>
/// Gets the RTC region for this audio channel.
/// </summary>
/// <remarks>
/// This property can be <see langword="null"/>.
/// </remarks>
string RTCRegion { get; }

/// <summary>
/// Connects to this audio channel.
/// </summary>


+ 2
- 0
src/Discord.Net.Rest/API/Common/Channel.cs View File

@@ -40,6 +40,8 @@ namespace Discord.API
public Optional<int> Bitrate { get; set; }
[JsonProperty("user_limit")]
public Optional<int> UserLimit { get; set; }
[JsonProperty("rtc_region")]
public Optional<string> RTCRegion { get; set; }

//PrivateChannel
[JsonProperty("recipients")]


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

@@ -22,6 +22,8 @@ namespace Discord.Rest

/// <inheritdoc />
public string Name { get; private set; }
/// <inheritdoc/>
public string RTCRegion { get; private set; }

public IReadOnlyCollection<RestGroupUser> Users => _users.ToReadOnlyCollection();
public IReadOnlyCollection<RestGroupUser> Recipients
@@ -46,6 +48,8 @@ namespace Discord.Rest

if (model.Recipients.IsSpecified)
UpdateUsers(model.Recipients.Value);

RTCRegion = model.RTCRegion.GetValueOrDefault(null);
}
internal void UpdateUsers(API.User[] models)
{


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

@@ -21,6 +21,8 @@ namespace Discord.Rest
public int? UserLimit { get; private set; }
/// <inheritdoc />
public ulong? CategoryId { get; private set; }
/// <inheritdoc/>
public string RTCRegion { get; private set; }

/// <inheritdoc />
public string Mention => MentionUtils.MentionChannel(Id);
@@ -46,6 +48,8 @@ namespace Discord.Rest

if(model.UserLimit.IsSpecified)
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;

RTCRegion = model.RTCRegion.GetValueOrDefault(null);
}

/// <inheritdoc />


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

@@ -30,6 +30,9 @@ namespace Discord.WebSocket
/// <inheritdoc />
public string Name { get; private set; }

/// <inheritdoc/>
public string RTCRegion { get; private set; }

/// <inheritdoc />
public IReadOnlyCollection<SocketMessage> CachedMessages => _messages?.Messages ?? ImmutableArray.Create<SocketMessage>();

@@ -67,6 +70,8 @@ namespace Discord.WebSocket

if (model.Recipients.IsSpecified)
UpdateUsers(state, model.Recipients.Value);

RTCRegion = model.RTCRegion.GetValueOrDefault(null);
}
private void UpdateUsers(ClientState state, UserModel[] models)
{


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

@@ -21,6 +21,8 @@ namespace Discord.WebSocket
public int Bitrate { get; private set; }
/// <inheritdoc />
public int? UserLimit { get; private set; }
/// <inheritdoc/>
public string RTCRegion { get; private set; }

/// <inheritdoc />
public ulong? CategoryId { get; private set; }
@@ -66,6 +68,7 @@ namespace Discord.WebSocket
CategoryId = model.CategoryId;
Bitrate = model.Bitrate.Value;
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
RTCRegion = model.RTCRegion.GetValueOrDefault(null);
}

/// <inheritdoc />


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

@@ -16,6 +16,8 @@ namespace Discord

public ulong Id => throw new NotImplementedException();

public string RTCRegion => throw new NotImplementedException();

public Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false)
{
throw new NotImplementedException();


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

@@ -29,6 +29,8 @@ namespace Discord
public DateTimeOffset CreatedAt => throw new NotImplementedException();
public ulong Id => throw new NotImplementedException();

public string RTCRegion => throw new NotImplementedException();

public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null)
{
throw new NotImplementedException();


Loading…
Cancel
Save