Browse Source

feature: Add GetEmotesAsync to IGuild (#1781)

tags/2.4.0
NeKz GitHub 4 years ago
parent
commit
df23d57458
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 0 deletions
  1. +9
    -0
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  2. +9
    -0
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  3. +5
    -0
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  4. +3
    -0
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  5. +3
    -0
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

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

@@ -892,6 +892,15 @@ namespace Discord
/// </returns>
Task<IReadOnlyCollection<IWebhook>> GetWebhooksAsync(RequestOptions options = null);

/// <summary>
/// Gets a collection of emotes from this guild.
/// </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 emotes found within the guild.
/// </returns>
Task<IReadOnlyCollection<GuildEmote>> GetEmotesAsync(RequestOptions options = null);
/// <summary>
/// Gets a specific emote from this guild.
/// </summary>


+ 9
- 0
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -1280,6 +1280,15 @@ namespace Discord.API
}

//Guild emoji
public async Task<IReadOnlyCollection<Emoji>> GetGuildEmotesAsync(ulong guildId, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
options = RequestOptions.CreateOrClone(options);

var ids = new BucketIds(guildId: guildId);
return await SendAsync<IReadOnlyCollection<Emoji>>("GET", () => $"guilds/{guildId}/emojis", ids, options: options).ConfigureAwait(false);
}

public async Task<Emoji> GetGuildEmoteAsync(ulong guildId, ulong emoteId, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));


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

@@ -496,6 +496,11 @@ namespace Discord.Rest
}

//Emotes
public static async Task<IReadOnlyCollection<GuildEmote>> GetEmotesAsync(IGuild guild, BaseDiscordClient client, RequestOptions options)
{
var models = await client.ApiClient.GetGuildEmotesAsync(guild.Id, options).ConfigureAwait(false);
return models.Select(x => x.ToEntity()).ToImmutableArray();
}
public static async Task<GuildEmote> GetEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, RequestOptions options)
{
var emote = await client.ApiClient.GetGuildEmoteAsync(guild.Id, id, options).ConfigureAwait(false);


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

@@ -828,6 +828,9 @@ namespace Discord.Rest

//Emotes
/// <inheritdoc />
public Task<IReadOnlyCollection<GuildEmote>> GetEmotesAsync(RequestOptions options = null)
=> GuildHelper.GetEmotesAsync(this, Discord, options);
/// <inheritdoc />
public Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null)
=> GuildHelper.GetEmoteAsync(this, Discord, id, options);
/// <inheritdoc />


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

@@ -1008,6 +1008,9 @@ namespace Discord.WebSocket

//Emotes
/// <inheritdoc />
public Task<IReadOnlyCollection<GuildEmote>> GetEmotesAsync(RequestOptions options = null)
=> GuildHelper.GetEmotesAsync(this, Discord, options);
/// <inheritdoc />
public Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null)
=> GuildHelper.GetEmoteAsync(this, Discord, id, options);
/// <inheritdoc />


Loading…
Cancel
Save