Browse Source

Get thread user implementation

pull/1923/head
quin lynch 3 years ago
parent
commit
4ceccbe9a3
2 changed files with 18 additions and 2 deletions
  1. +13
    -1
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  2. +5
    -1
      src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs

+ 13
- 1
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -525,7 +525,19 @@ namespace Discord.API

var bucket = new BucketIds(channelId: channelId);

return await SendAsync<ThreadMember[]>("GET", () => $"channels/{channelId}/thread-members", bucket, options: options);
return await SendAsync<ThreadMember[]>("GET", () => $"channels/{channelId}/thread-members", bucket, options: options).ConfigureAwait(false);
}

public async Task<ThreadMember> 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<ThreadMember>("GET", () => $"channels/{channelId}/thread-members/{userId}", bucket, options: options).ConfigureAwait(false);
}

public async Task<ChannelThreads> GetActiveThreadsAsync(ulong channelId, RequestOptions options = null)


+ 5
- 1
src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs View File

@@ -63,6 +63,10 @@ namespace Discord.Rest
}

public static async Task<RestThreadUser> 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);
}
}
}

Loading…
Cancel
Save