From 3c462012e2fe06a4cc91fc05805094f829f3f3be Mon Sep 17 00:00:00 2001 From: Filip Strajnar Date: Tue, 18 Jun 2024 20:16:15 +0200 Subject: [PATCH] Returning HttpData instead of tuples. --- DiscordClient/DiscordUserClient.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/DiscordClient/DiscordUserClient.cs b/DiscordClient/DiscordUserClient.cs index 35008be..168de0e 100644 --- a/DiscordClient/DiscordUserClient.cs +++ b/DiscordClient/DiscordUserClient.cs @@ -37,16 +37,20 @@ public class DiscordUserClient return await GetShortProfile("@me"); } - public async Task<( - HttpResponseMessage Response, - MessageSearchResponse? JsonData - )> GetChannelMessages(string channelId, int offset = 0, string? authorId = null) + public async Task> GetChannelMessages( + string channelId, + int offset = 0, + string? authorId = null + ) { string authorQuery = authorId is not null ? $"&author_id={authorId}" : ""; string url = $"https://discord.com/api/v9/channels/{channelId}/messages/search?offset={offset}{authorQuery}"; HttpResponseMessage response = await _httpClient.GetAsync(url); - return (response, await response.Content.ReadFromJsonAsync()); + return new HttpData( + response, + await response.Content.ReadFromJsonAsync() + ); } sealed class MessageContent @@ -84,15 +88,19 @@ public class DiscordUserClient /// recent messages from this particular author. /// /// - public async Task<( - HttpResponseMessage Response, - MessageSearchResponse? JsonData - )> SearchGuildMessages(string guildId, int offset, string? authorId = null) + public async Task> SearchGuildMessages( + string guildId, + int offset, + string? authorId = null + ) { string authorQuery = authorId is not null ? $"&author_id={authorId}" : ""; string url = $"https://discord.com/api/v9/guilds/{guildId}/messages/search?offset={offset}{authorQuery}"; HttpResponseMessage response = await _httpClient.GetAsync(url); - return (response, await response.Content.ReadFromJsonAsync()); + return new HttpData( + response, + await response.Content.ReadFromJsonAsync() + ); } }