mirror of
https://onedev.fprog.nl/DiscordClient
synced 2025-12-29 10:18:36 +01:00
Returning HttpData instead of tuples.
This commit is contained in:
parent
8b65461267
commit
3c462012e2
|
|
@ -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<HttpData<MessageSearchResponse>> 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<MessageSearchResponse>());
|
||||
return new HttpData<MessageSearchResponse>(
|
||||
response,
|
||||
await response.Content.ReadFromJsonAsync<MessageSearchResponse>()
|
||||
);
|
||||
}
|
||||
|
||||
sealed class MessageContent
|
||||
|
|
@ -84,15 +88,19 @@ public class DiscordUserClient
|
|||
/// recent messages from this particular author.
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public async Task<(
|
||||
HttpResponseMessage Response,
|
||||
MessageSearchResponse? JsonData
|
||||
)> SearchGuildMessages(string guildId, int offset, string? authorId = null)
|
||||
public async Task<HttpData<MessageSearchResponse>> 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<MessageSearchResponse>());
|
||||
return new HttpData<MessageSearchResponse>(
|
||||
response,
|
||||
await response.Content.ReadFromJsonAsync<MessageSearchResponse>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue