Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
Add RTCRegion (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
quinchs authored Dec 24, 2021
1 parent 7039098 commit 48a9637
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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>
Expand Down
2 changes: 2 additions & 0 deletions src/Discord.Net.Rest/API/Common/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ internal class Channel
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")]
Expand Down
4 changes: 4 additions & 0 deletions src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class RestGroupChannel : RestChannel, IGroupChannel, IRestPrivateChannel,

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

public IReadOnlyCollection<RestGroupUser> Users => _users.ToReadOnlyCollection();
public IReadOnlyCollection<RestGroupUser> Recipients
Expand All @@ -46,6 +48,8 @@ internal override void Update(Model model)

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

RTCRegion = model.RTCRegion.GetValueOrDefault(null);
}
internal void UpdateUsers(API.User[] models)
{
Expand Down
5 changes: 4 additions & 1 deletion src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChann
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);

Expand All @@ -46,6 +47,8 @@ internal override void Update(Model model)

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

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

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class SocketGroupChannel : SocketChannel, IGroupChannel, ISocketPrivateCh
/// <inheritdoc />
public string Name { get; private set; }

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

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

Expand Down Expand Up @@ -67,6 +70,8 @@ internal override void Update(ClientState state, Model model)

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

RTCRegion = model.RTCRegion.GetValueOrDefault(null);
}
private void UpdateUsers(ClientState state, UserModel[] models)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class SocketVoiceChannel : SocketGuildChannel, IVoiceChannel, ISocketAudi
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; }
Expand Down Expand Up @@ -66,6 +68,7 @@ internal override void Update(ClientState state, Model model)
CategoryId = model.CategoryId;
Bitrate = model.Bitrate.Value;
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
RTCRegion = model.RTCRegion.GetValueOrDefault(null);
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ internal sealed class MockedGroupChannel : IGroupChannel

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ internal sealed class MockedVoiceChannel : IVoiceChannel
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();
Expand Down

0 comments on commit 48a9637

Please sign in to comment.