Skip to content

Commit

Permalink
Fixed FetchApplicationEmojisAsync throwing
Browse files Browse the repository at this point in the history
GET /applications/{application.id}/emojis returns the emojis under a nested "items" object instead of returning an array directly. oops
  • Loading branch information
QuantumToasted committed Aug 5, 2024
1 parent 976ccda commit 62010f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Disqord.Serialization.Json;

namespace Disqord.Models;

public class ApplicationEmojisJsonModel : JsonModel
{
[JsonProperty("items")]
public EmojiJsonModel[] Items = null!;
}
4 changes: 2 additions & 2 deletions src/Disqord.Rest.Api/Methods/RestApiClientExtensions.Emoji.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace Disqord.Rest.Api;

public static partial class RestApiClientExtensions
{
public static Task<EmojiJsonModel[]> FetchApplicationEmojisAsync(this IRestApiClient client,
public static Task<ApplicationEmojisJsonModel> FetchApplicationEmojisAsync(this IRestApiClient client,
Snowflake applicationId,
IRestRequestOptions? options = null, CancellationToken cancellationToken = default)
{
var route = Format(Route.Emoji.GetApplicationEmojis, applicationId);
return client.ExecuteAsync<EmojiJsonModel[]>(route, null, options, cancellationToken);
return client.ExecuteAsync<ApplicationEmojisJsonModel>(route, null, options, cancellationToken);
}

public static Task<EmojiJsonModel> FetchApplicationEmojiAsync(this IRestApiClient client,
Expand Down
4 changes: 2 additions & 2 deletions src/Disqord.Rest/Extensions/RestClientExtensions.Emoji.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public static async Task<IReadOnlyList<IApplicationEmoji>> FetchApplicationEmoji
Snowflake applicationId,
IRestRequestOptions? options = null, CancellationToken cancellationToken = default)
{
var models = await client.ApiClient.FetchApplicationEmojisAsync(applicationId, options, cancellationToken).ConfigureAwait(false);
return models.ToReadOnlyList((client, applicationId), static (model, state) =>
var model = await client.ApiClient.FetchApplicationEmojisAsync(applicationId, options, cancellationToken).ConfigureAwait(false);
return model.Items.ToReadOnlyList((client, applicationId), static (model, state) =>
{
var (client, applicationId) = state;
return new TransientApplicationEmoji(client, applicationId, model);
Expand Down

0 comments on commit 62010f3

Please sign in to comment.