Added option to search by author's ID.

This commit is contained in:
Filip Strajnar 2024-04-25 23:56:13 +02:00
parent d1504ed4e8
commit 02b5619d15

View file

@ -21,10 +21,13 @@ public class DiscordUserClient
public async Task<ChannelMessagesResponse[]?> GetChannelMessages(
string channelId,
int offset = 0,
string? authorId = null,
int limit = 50
)
{
string url = $"https://discord.com/api/v9/channels/{channelId}/messages?limit={limit}&offset={offset}";
string authorQuery = authorId is not null ? $"&author_id={authorId}" : "";
string url =
$"https://discord.com/api/v9/channels/{channelId}/messages?limit={limit}&offset={offset}{authorQuery}";
HttpResponseMessage response = await _httpClient.GetAsync(url);
return await response.Content.ReadFromJsonAsync<ChannelMessagesResponse[]>();
}