diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index a6c971842..1c4540fe8 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -595,31 +595,15 @@ namespace Discord.API return await SendAsync("GET", () => $"guilds/{guildId}/threads/active", bucket, options: options); } - public async Task GetActiveThreadsInChannelAsync(ulong guildId, ulong parentChannel, RequestOptions options = null) + public async Task GetActiveThreadsInChannelAsync(ulong channelId, RequestOptions options = null) { - Preconditions.NotEqual(guildId, 0, nameof(guildId)); + Preconditions.NotEqual(channelId, 0, nameof(channelId)); options = RequestOptions.CreateOrClone(options); - var bucket = new BucketIds(guildId: guildId); - - ChannelThreads allChannelThreads = await SendAsync("GET", () => $"guilds/{guildId}/threads/active", bucket, options: options); - ChannelThreads filteredThreads = new ChannelThreads(); - - filteredThreads.Threads = allChannelThreads.Threads.Where(x => x.CategoryId == parentChannel).ToArray(); - - List members = new List(); - - foreach (ThreadMember m in allChannelThreads.Members) - { - if (filteredThreads.Threads.Where(x => x.Id == (ulong)m.Id).Count() == 0) - continue; - members.Add(m); - } - - filteredThreads.Members = members.ToArray(); + var bucket = new BucketIds(channelId: channelId); - return filteredThreads; + return await SendAsync("GET", () => $"channels/{channelId}/threads/active", bucket, options: options); } public async Task GetPublicArchivedThreadsAsync(ulong channelId, DateTimeOffset? before = null, int? limit = null, RequestOptions options = null) diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs index 7bef98d28..4357c1558 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs @@ -236,7 +236,7 @@ namespace Discord.Rest /// public Task> GetActiveThreadsAsync(RequestOptions options = null) - => ThreadHelper.GetActiveThreadsInChannelAsync(Guild, this, Discord, options); + => ThreadHelper.GetActiveThreadsInChannelAsync(this, Discord, options); /// public Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) diff --git a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs index 7e0494e58..847279b19 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs @@ -67,10 +67,10 @@ namespace Discord.Rest var result = await client.ApiClient.GetActiveThreadsAsync(guild.Id, options).ConfigureAwait(false); return result.Threads.Select(x => RestThreadChannel.Create(client, guild, x)).ToImmutableArray(); } - public static async Task> GetActiveThreadsInChannelAsync(IGuild guild, IGuildChannel parentChannel, BaseDiscordClient client, RequestOptions options) + public static async Task> GetActiveThreadsInChannelAsync(IGuildChannel channel, BaseDiscordClient client, RequestOptions options) { - var result = await client.ApiClient.GetActiveThreadsInChannelAsync(guild.Id, parentChannel.Id, options).ConfigureAwait(false); - return result.Threads.Select(x => RestThreadChannel.Create(client, guild, x)).ToImmutableArray(); + var result = await client.ApiClient.GetActiveThreadsInChannelAsync(channel.Id, options).ConfigureAwait(false); + return result.Threads.Select(x => RestThreadChannel.Create(client, channel.Guild, x)).ToImmutableArray(); } public static async Task> GetPublicArchivedThreadsAsync(IGuildChannel channel, BaseDiscordClient client, int? limit = null, diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs index d3dc1f138..97a2e8268 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs @@ -179,7 +179,7 @@ namespace Discord.WebSocket /// public Task> GetActiveThreadsAsync(RequestOptions options = null) - => ThreadHelper.GetActiveThreadsInChannelAsync(Guild, this, Discord, options); + => ThreadHelper.GetActiveThreadsInChannelAsync(this, Discord, options); /// public Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null)