Browse Source

Implemented GetVoiceRegionsAsync on IGuild. (#1166)

tags/2.0
advorange Christopher F 6 years ago
parent
commit
00717cf481
4 changed files with 49 additions and 0 deletions
  1. +10
    -0
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  2. +8
    -0
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  3. +15
    -0
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  4. +16
    -0
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 10
- 0
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -467,6 +467,16 @@ namespace Discord
/// </returns>
Task<ICategoryChannel> CreateCategoryAsync(string name, RequestOptions options = null);

/// <summary>
/// Gets a collection of all the voice regions this guild can access.
/// </summary>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains a read-only collection of
/// voice regions the guild can access.
/// </returns>
Task<IReadOnlyCollection<IVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null);

Task<IReadOnlyCollection<IGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null);
Task<IGuildIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null);



+ 8
- 0
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -192,6 +192,14 @@ namespace Discord.Rest
return RestCategoryChannel.Create(client, guild, model);
}

//Voice Regions
public static async Task<IReadOnlyCollection<RestVoiceRegion>> 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<IReadOnlyCollection<RestGuildIntegration>> GetIntegrationsAsync(IGuild guild, BaseDiscordClient client,
RequestOptions options)


+ 15
- 0
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -443,6 +443,17 @@ namespace Discord.Rest
public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options);

/// <summary>
/// Gets a collection of all the voice regions this guild can access.
/// </summary>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains a read-only collection of
/// voice regions the guild can access.
/// </returns>
public Task<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
=> GuildHelper.GetVoiceRegionsAsync(this, Discord, options);

//Integrations
public Task<IReadOnlyCollection<RestGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null)
=> GuildHelper.GetIntegrationsAsync(this, Discord, options);
@@ -758,6 +769,10 @@ namespace Discord.Rest
async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, RequestOptions options)
=> await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);

/// <inheritdoc />
async Task<IReadOnlyCollection<IVoiceRegion>> IGuild.GetVoiceRegionsAsync(RequestOptions options)
=> await GetVoiceRegionsAsync(options).ConfigureAwait(false);

/// <inheritdoc />
async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
=> await GetIntegrationsAsync(options).ConfigureAwait(false);


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

@@ -578,6 +578,18 @@ namespace Discord.WebSocket
return null;
}

//Voice Regions
/// <summary>
/// Gets a collection of all the voice regions this guild can access.
/// </summary>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains a read-only collection of
/// voice regions the guild can access.
/// </returns>
public Task<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
=> GuildHelper.GetVoiceRegionsAsync(this, Discord, options);

//Integrations
public Task<IReadOnlyCollection<RestGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null)
=> GuildHelper.GetIntegrationsAsync(this, Discord, options);
@@ -1050,6 +1062,10 @@ namespace Discord.WebSocket
async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, RequestOptions options)
=> await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);

/// <inheritdoc />
async Task<IReadOnlyCollection<IVoiceRegion>> IGuild.GetVoiceRegionsAsync(RequestOptions options)
=> await GetVoiceRegionsAsync(options).ConfigureAwait(false);

/// <inheritdoc />
async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
=> await GetIntegrationsAsync(options).ConfigureAwait(false);


Loading…
Cancel
Save