Skip to content

Commit 2a416a3

Browse files
authored
Add RTCRegion to voice channels (#2002)
* Add RTCRegion to voice channels * Update MockedGroupChannel.cs
1 parent 144741e commit 2a416a3

File tree

8 files changed

+30
-0
lines changed

8 files changed

+30
-0
lines changed

src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ namespace Discord
99
/// </summary>
1010
public interface IAudioChannel : IChannel
1111
{
12+
/// <summary>
13+
/// Gets the RTC region for this audio channel.
14+
/// </summary>
15+
/// <remarks>
16+
/// This property can be <see langword="null"/>.
17+
/// </remarks>
18+
string RTCRegion { get; }
19+
1220
/// <summary>
1321
/// Connects to this audio channel.
1422
/// </summary>

src/Discord.Net.Rest/API/Common/Channel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ internal class Channel
4040
public Optional<int> Bitrate { get; set; }
4141
[JsonProperty("user_limit")]
4242
public Optional<int> UserLimit { get; set; }
43+
[JsonProperty("rtc_region")]
44+
public Optional<string> RTCRegion { get; set; }
4345

4446
//PrivateChannel
4547
[JsonProperty("recipients")]

src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class RestGroupChannel : RestChannel, IGroupChannel, IRestPrivateChannel,
2222

2323
/// <inheritdoc />
2424
public string Name { get; private set; }
25+
/// <inheritdoc/>
26+
public string RTCRegion { get; private set; }
2527

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

4749
if (model.Recipients.IsSpecified)
4850
UpdateUsers(model.Recipients.Value);
51+
52+
RTCRegion = model.RTCRegion.GetValueOrDefault(null);
4953
}
5054
internal void UpdateUsers(API.User[] models)
5155
{

src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChann
2121
public int? UserLimit { get; private set; }
2222
/// <inheritdoc />
2323
public ulong? CategoryId { get; private set; }
24+
/// <inheritdoc/>
25+
public string RTCRegion { get; private set; }
2426

2527
/// <inheritdoc />
2628
public string Mention => MentionUtils.MentionChannel(Id);
@@ -46,6 +48,8 @@ internal override void Update(Model model)
4648

4749
if(model.UserLimit.IsSpecified)
4850
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
51+
52+
RTCRegion = model.RTCRegion.GetValueOrDefault(null);
4953
}
5054

5155
/// <inheritdoc />

src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public class SocketGroupChannel : SocketChannel, IGroupChannel, ISocketPrivateCh
3030
/// <inheritdoc />
3131
public string Name { get; private set; }
3232

33+
/// <inheritdoc/>
34+
public string RTCRegion { get; private set; }
35+
3336
/// <inheritdoc />
3437
public IReadOnlyCollection<SocketMessage> CachedMessages => _messages?.Messages ?? ImmutableArray.Create<SocketMessage>();
3538

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

6871
if (model.Recipients.IsSpecified)
6972
UpdateUsers(state, model.Recipients.Value);
73+
74+
RTCRegion = model.RTCRegion.GetValueOrDefault(null);
7075
}
7176
private void UpdateUsers(ClientState state, UserModel[] models)
7277
{

src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class SocketVoiceChannel : SocketGuildChannel, IVoiceChannel, ISocketAudi
2121
public int Bitrate { get; private set; }
2222
/// <inheritdoc />
2323
public int? UserLimit { get; private set; }
24+
/// <inheritdoc/>
25+
public string RTCRegion { get; private set; }
2426

2527
/// <inheritdoc />
2628
public ulong? CategoryId { get; private set; }
@@ -66,6 +68,7 @@ internal override void Update(ClientState state, Model model)
6668
CategoryId = model.CategoryId;
6769
Bitrate = model.Bitrate.Value;
6870
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
71+
RTCRegion = model.RTCRegion.GetValueOrDefault(null);
6972
}
7073

7174
/// <inheritdoc />

test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ internal sealed class MockedGroupChannel : IGroupChannel
1616

1717
public ulong Id => throw new NotImplementedException();
1818

19+
public string RTCRegion => throw new NotImplementedException();
20+
1921
public Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false)
2022
{
2123
throw new NotImplementedException();

test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ internal sealed class MockedVoiceChannel : IVoiceChannel
2929
public DateTimeOffset CreatedAt => throw new NotImplementedException();
3030
public ulong Id => throw new NotImplementedException();
3131

32+
public string RTCRegion => throw new NotImplementedException();
33+
3234
public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null)
3335
{
3436
throw new NotImplementedException();

0 commit comments

Comments
 (0)