mirror of
https://onedev.fprog.nl/DiscordClient
synced 2026-01-08 10:13:41 +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");
|
return await GetShortProfile("@me");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(
|
public async Task<HttpData<MessageSearchResponse>> GetChannelMessages(
|
||||||
HttpResponseMessage Response,
|
string channelId,
|
||||||
MessageSearchResponse? JsonData
|
int offset = 0,
|
||||||
)> GetChannelMessages(string channelId, int offset = 0, string? authorId = null)
|
string? authorId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
string authorQuery = authorId is not null ? $"&author_id={authorId}" : "";
|
string authorQuery = authorId is not null ? $"&author_id={authorId}" : "";
|
||||||
string url =
|
string url =
|
||||||
$"https://discord.com/api/v9/channels/{channelId}/messages/search?offset={offset}{authorQuery}";
|
$"https://discord.com/api/v9/channels/{channelId}/messages/search?offset={offset}{authorQuery}";
|
||||||
HttpResponseMessage response = await _httpClient.GetAsync(url);
|
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
|
sealed class MessageContent
|
||||||
|
|
@ -84,15 +88,19 @@ public class DiscordUserClient
|
||||||
/// recent messages from this particular author.
|
/// recent messages from this particular author.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<(
|
public async Task<HttpData<MessageSearchResponse>> SearchGuildMessages(
|
||||||
HttpResponseMessage Response,
|
string guildId,
|
||||||
MessageSearchResponse? JsonData
|
int offset,
|
||||||
)> SearchGuildMessages(string guildId, int offset, string? authorId = null)
|
string? authorId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
string authorQuery = authorId is not null ? $"&author_id={authorId}" : "";
|
string authorQuery = authorId is not null ? $"&author_id={authorId}" : "";
|
||||||
string url =
|
string url =
|
||||||
$"https://discord.com/api/v9/guilds/{guildId}/messages/search?offset={offset}{authorQuery}";
|
$"https://discord.com/api/v9/guilds/{guildId}/messages/search?offset={offset}{authorQuery}";
|
||||||
HttpResponseMessage response = await _httpClient.GetAsync(url);
|
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