From 00717cf4812b0e1388c4fbd3f266f1bfab80d134 Mon Sep 17 00:00:00 2001 From: advorange Date: Tue, 2 Oct 2018 13:26:35 -0700 Subject: [PATCH] Implemented GetVoiceRegionsAsync on IGuild. (#1166) --- src/Discord.Net.Core/Entities/Guilds/IGuild.cs | 10 ++++++++++ .../Entities/Guilds/GuildHelper.cs | 8 ++++++++ .../Entities/Guilds/RestGuild.cs | 15 +++++++++++++++ .../Entities/Guilds/SocketGuild.cs | 16 ++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index 8f9108d95..9b91b9440 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -467,6 +467,16 @@ namespace Discord /// Task CreateCategoryAsync(string name, RequestOptions options = null); + /// + /// Gets a collection of all the voice regions this guild can access. + /// + /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous get operation. The task result contains a read-only collection of + /// voice regions the guild can access. + /// + Task> GetVoiceRegionsAsync(RequestOptions options = null); + Task> GetIntegrationsAsync(RequestOptions options = null); Task CreateIntegrationAsync(ulong id, string type, RequestOptions options = null); diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs index 823d41a05..b8b66f802 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs @@ -192,6 +192,14 @@ namespace Discord.Rest return RestCategoryChannel.Create(client, guild, model); } + //Voice Regions + public static async Task> GetVoiceRegionsAsync(IGuild guild, BaseDiscordClient client, + RequestOptions options) + { + var models = await client.ApiClient.GetGuildVoiceRegionsAsync(guild.Id, options).ConfigureAwait(false); + return models.Select(x => RestVoiceRegion.Create(client, x)).ToImmutableArray(); + } + //Integrations public static async Task> GetIntegrationsAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index fda9b609d..9c4ecd848 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -443,6 +443,17 @@ namespace Discord.Rest public Task CreateCategoryChannelAsync(string name, RequestOptions options = null) => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options); + /// + /// Gets a collection of all the voice regions this guild can access. + /// + /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous get operation. The task result contains a read-only collection of + /// voice regions the guild can access. + /// + public Task> GetVoiceRegionsAsync(RequestOptions options = null) + => GuildHelper.GetVoiceRegionsAsync(this, Discord, options); + //Integrations public Task> GetIntegrationsAsync(RequestOptions options = null) => GuildHelper.GetIntegrationsAsync(this, Discord, options); @@ -758,6 +769,10 @@ namespace Discord.Rest async Task IGuild.CreateCategoryAsync(string name, RequestOptions options) => await CreateCategoryChannelAsync(name, options).ConfigureAwait(false); + /// + async Task> IGuild.GetVoiceRegionsAsync(RequestOptions options) + => await GetVoiceRegionsAsync(options).ConfigureAwait(false); + /// async Task> IGuild.GetIntegrationsAsync(RequestOptions options) => await GetIntegrationsAsync(options).ConfigureAwait(false); diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index 06b048872..b4f87e12a 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -578,6 +578,18 @@ namespace Discord.WebSocket return null; } + //Voice Regions + /// + /// Gets a collection of all the voice regions this guild can access. + /// + /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous get operation. The task result contains a read-only collection of + /// voice regions the guild can access. + /// + public Task> GetVoiceRegionsAsync(RequestOptions options = null) + => GuildHelper.GetVoiceRegionsAsync(this, Discord, options); + //Integrations public Task> GetIntegrationsAsync(RequestOptions options = null) => GuildHelper.GetIntegrationsAsync(this, Discord, options); @@ -1050,6 +1062,10 @@ namespace Discord.WebSocket async Task IGuild.CreateCategoryAsync(string name, RequestOptions options) => await CreateCategoryChannelAsync(name, options).ConfigureAwait(false); + /// + async Task> IGuild.GetVoiceRegionsAsync(RequestOptions options) + => await GetVoiceRegionsAsync(options).ConfigureAwait(false); + /// async Task> IGuild.GetIntegrationsAsync(RequestOptions options) => await GetIntegrationsAsync(options).ConfigureAwait(false);