From 4ceccbe9a3bf855778244ecc3ff85668388f33d2 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Mon, 1 Nov 2021 18:13:02 -0300 Subject: [PATCH] Get thread user implementation --- src/Discord.Net.Rest/DiscordRestApiClient.cs | 14 +++++++++++++- .../Entities/Channels/ThreadHelper.cs | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 48fafd090..75a0118d3 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -525,7 +525,19 @@ namespace Discord.API var bucket = new BucketIds(channelId: channelId); - return await SendAsync("GET", () => $"channels/{channelId}/thread-members", bucket, options: options); + return await SendAsync("GET", () => $"channels/{channelId}/thread-members", bucket, options: options).ConfigureAwait(false); + } + + public async Task GetThreadMemberAsync(ulong channelId, ulong userId, RequestOptions options = null) + { + Preconditions.NotEqual(channelId, 0, nameof(channelId)); + Preconditions.NotEqual(userId, 0, nameof(userId)); + + options = RequestOptions.CreateOrClone(options); + + var bucket = new BucketIds(channelId: channelId); + + return await SendAsync("GET", () => $"channels/{channelId}/thread-members/{userId}", bucket, options: options).ConfigureAwait(false); } public async Task GetActiveThreadsAsync(ulong channelId, RequestOptions options = null) diff --git a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs index 4c2bec8e2..8537e887c 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs @@ -63,6 +63,10 @@ namespace Discord.Rest } public static async Task GetUserAsync(ulong userId, IThreadChannel channel, BaseDiscordClient client, RequestOptions options = null) - => (await GetUsersAsync(channel, client, options).ConfigureAwait(false)).FirstOrDefault(x => x.Id == userId); + { + var model = await client.ApiClient.GetThreadMemberAsync(channel.Id, userId, options).ConfigureAwait(false); + + return RestThreadUser.Create(client, channel.Guild, model, channel); + } } }