feature: Add GetEmotesAsync to IGuild (#1781)

This commit is contained in:
NeKz
2021-04-28 16:08:56 +02:00
committed by GitHub
parent 0715d7db96
commit df23d57458
5 changed files with 29 additions and 0 deletions

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>

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));

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);

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 />

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 />