@@ -584,7 +584,7 @@ namespace Discord.API | |||||
return await SendAsync<ThreadMember>("GET", () => $"channels/{channelId}/thread-members/{userId}", bucket, options: options).ConfigureAwait(false); | return await SendAsync<ThreadMember>("GET", () => $"channels/{channelId}/thread-members/{userId}", bucket, options: options).ConfigureAwait(false); | ||||
} | } | ||||
public async Task<ChannelThreads> GetActiveThreadsInGuildAsync(ulong guildId, RequestOptions options = null) | |||||
public async Task<ChannelThreads> GetActiveThreadsAsync(ulong guildId, RequestOptions options = null) | |||||
{ | { | ||||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
@@ -595,18 +595,34 @@ namespace Discord.API | |||||
return await SendAsync<ChannelThreads>("GET", () => $"guilds/{guildId}/threads/active", bucket, options: options); | return await SendAsync<ChannelThreads>("GET", () => $"guilds/{guildId}/threads/active", bucket, options: options); | ||||
} | } | ||||
public async Task<ChannelThreads> GetActiveThreadsInChannelAsync(ulong channelId, RequestOptions options = null) | |||||
public async Task<ChannelThreads> GetActiveThreadsInChannelAsync(ulong guildId, ulong parentChannel, RequestOptions options = null) | |||||
{ | { | ||||
Preconditions.NotEqual(channelId, 0, nameof(channelId)); | |||||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||||
options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
var bucket = new BucketIds(channelId: channelId); | |||||
var bucket = new BucketIds(guildId: guildId); | |||||
ChannelThreads allChannelThreads = await SendAsync<ChannelThreads>("GET", () => $"guilds/{guildId}/threads/active", bucket, options: options); | |||||
ChannelThreads filteredThreads = new ChannelThreads(); | |||||
filteredThreads.Threads = allChannelThreads.Threads.Where(x => x.CategoryId == parentChannel).ToArray(); | |||||
List<ThreadMember> members = new List<ThreadMember>(); | |||||
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(); | |||||
return await SendAsync<ChannelThreads>("GET", () => $"channels/{channelId}/threads/active", bucket, options: options); | |||||
return filteredThreads; | |||||
} | } | ||||
public async Task<ChannelThreads> GetPublicArchivedThreadsInChannelAsync(ulong channelId, DateTimeOffset? before = null, int? limit = null, RequestOptions options = null) | |||||
public async Task<ChannelThreads> GetPublicArchivedThreadsAsync(ulong channelId, DateTimeOffset? before = null, int? limit = null, RequestOptions options = null) | |||||
{ | { | ||||
Preconditions.NotEqual(channelId, 0, nameof(channelId)); | Preconditions.NotEqual(channelId, 0, nameof(channelId)); | ||||
@@ -628,7 +644,7 @@ namespace Discord.API | |||||
return await SendAsync<ChannelThreads>("GET", () => $"channels/{channelId}/threads/archived/public{query}", bucket, options: options); | return await SendAsync<ChannelThreads>("GET", () => $"channels/{channelId}/threads/archived/public{query}", bucket, options: options); | ||||
} | } | ||||
public async Task<ChannelThreads> GetPrivateArchivedThreadsInChannelAsync(ulong channelId, DateTimeOffset? before = null, int? limit = null, | |||||
public async Task<ChannelThreads> GetPrivateArchivedThreadsAsync(ulong channelId, DateTimeOffset? before = null, int? limit = null, | |||||
RequestOptions options = null) | RequestOptions options = null) | ||||
{ | { | ||||
Preconditions.NotEqual(channelId, 0, nameof(channelId)); | Preconditions.NotEqual(channelId, 0, nameof(channelId)); | ||||
@@ -651,7 +667,7 @@ namespace Discord.API | |||||
return await SendAsync<ChannelThreads>("GET", () => $"channels/{channelId}/threads/archived/private{query}", bucket, options: options); | return await SendAsync<ChannelThreads>("GET", () => $"channels/{channelId}/threads/archived/private{query}", bucket, options: options); | ||||
} | } | ||||
public async Task<ChannelThreads> GetJoinedPrivateArchivedThreadsInChannelAsync(ulong channelId, DateTimeOffset? before = null, int? limit = null, | |||||
public async Task<ChannelThreads> GetJoinedPrivateArchivedThreadsAsync(ulong channelId, DateTimeOffset? before = null, int? limit = null, | |||||
RequestOptions options = null) | RequestOptions options = null) | ||||
{ | { | ||||
Preconditions.NotEqual(channelId, 0, nameof(channelId)); | Preconditions.NotEqual(channelId, 0, nameof(channelId)); | ||||
@@ -236,7 +236,7 @@ namespace Discord.Rest | |||||
/// <inheritdoc cref="IGuildChannel.GetActiveThreadsAsync(RequestOptions)"/> | /// <inheritdoc cref="IGuildChannel.GetActiveThreadsAsync(RequestOptions)"/> | ||||
public Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null) | ||||
=> ThreadHelper.GetActiveThreadsAsync(this, Discord, options); | |||||
=> ThreadHelper.GetActiveThreadsInChannelAsync(Guild, this, Discord, options); | |||||
/// <inheritdoc cref="IGuildChannel.GetPublicArchivedThreadsAsync(int?, DateTimeOffset?, RequestOptions)"/> | /// <inheritdoc cref="IGuildChannel.GetPublicArchivedThreadsAsync(int?, DateTimeOffset?, RequestOptions)"/> | ||||
public Task<IReadOnlyCollection<RestThreadChannel>> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) | public Task<IReadOnlyCollection<RestThreadChannel>> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) | ||||
@@ -64,33 +64,33 @@ namespace Discord.Rest | |||||
public static async Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) | public static async Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) | ||||
{ | { | ||||
var result = await client.ApiClient.GetActiveThreadsInGuildAsync(guild.Id, options).ConfigureAwait(false); | |||||
var result = await client.ApiClient.GetActiveThreadsAsync(guild.Id, options).ConfigureAwait(false); | |||||
return result.Threads.Select(x => RestThreadChannel.Create(client, guild, x)).ToImmutableArray(); | return result.Threads.Select(x => RestThreadChannel.Create(client, guild, x)).ToImmutableArray(); | ||||
} | } | ||||
public static async Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(IGuildChannel channel, BaseDiscordClient client, RequestOptions options) | |||||
public static async Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsInChannelAsync(IGuild guild, IGuildChannel parentChannel, BaseDiscordClient client, RequestOptions options) | |||||
{ | { | ||||
var result = await client.ApiClient.GetActiveThreadsInChannelAsync(channel.Id, options).ConfigureAwait(false); | |||||
return result.Threads.Select(x => RestThreadChannel.Create(client, channel.Guild, x)).ToImmutableArray(); | |||||
var result = await client.ApiClient.GetActiveThreadsInChannelAsync(guild.Id, parentChannel.Id, options).ConfigureAwait(false); | |||||
return result.Threads.Select(x => RestThreadChannel.Create(client, guild, x)).ToImmutableArray(); | |||||
} | } | ||||
public static async Task<IReadOnlyCollection<RestThreadChannel>> GetPublicArchivedThreadsAsync(IGuildChannel channel, BaseDiscordClient client, int? limit = null, | public static async Task<IReadOnlyCollection<RestThreadChannel>> GetPublicArchivedThreadsAsync(IGuildChannel channel, BaseDiscordClient client, int? limit = null, | ||||
DateTimeOffset? before = null, RequestOptions options = null) | DateTimeOffset? before = null, RequestOptions options = null) | ||||
{ | { | ||||
var result = await client.ApiClient.GetPublicArchivedThreadsInChannelAsync(channel.Id, before, limit, options); | |||||
var result = await client.ApiClient.GetPublicArchivedThreadsAsync(channel.Id, before, limit, options); | |||||
return result.Threads.Select(x => RestThreadChannel.Create(client, channel.Guild, x)).ToImmutableArray(); | return result.Threads.Select(x => RestThreadChannel.Create(client, channel.Guild, x)).ToImmutableArray(); | ||||
} | } | ||||
public static async Task<IReadOnlyCollection<RestThreadChannel>> GetPrivateArchivedThreadsAsync(IGuildChannel channel, BaseDiscordClient client, int? limit = null, | public static async Task<IReadOnlyCollection<RestThreadChannel>> GetPrivateArchivedThreadsAsync(IGuildChannel channel, BaseDiscordClient client, int? limit = null, | ||||
DateTimeOffset? before = null, RequestOptions options = null) | DateTimeOffset? before = null, RequestOptions options = null) | ||||
{ | { | ||||
var result = await client.ApiClient.GetPrivateArchivedThreadsInChannelAsync(channel.Id, before, limit, options); | |||||
var result = await client.ApiClient.GetPrivateArchivedThreadsAsync(channel.Id, before, limit, options); | |||||
return result.Threads.Select(x => RestThreadChannel.Create(client, channel.Guild, x)).ToImmutableArray(); | return result.Threads.Select(x => RestThreadChannel.Create(client, channel.Guild, x)).ToImmutableArray(); | ||||
} | } | ||||
public static async Task<IReadOnlyCollection<RestThreadChannel>> GetJoinedPrivateArchivedThreadsAsync(IGuildChannel channel, BaseDiscordClient client, int? limit = null, | public static async Task<IReadOnlyCollection<RestThreadChannel>> GetJoinedPrivateArchivedThreadsAsync(IGuildChannel channel, BaseDiscordClient client, int? limit = null, | ||||
DateTimeOffset? before = null, RequestOptions options = null) | DateTimeOffset? before = null, RequestOptions options = null) | ||||
{ | { | ||||
var result = await client.ApiClient.GetJoinedPrivateArchivedThreadsInChannelAsync(channel.Id, before, limit, options); | |||||
var result = await client.ApiClient.GetJoinedPrivateArchivedThreadsAsync(channel.Id, before, limit, options); | |||||
return result.Threads.Select(x => RestThreadChannel.Create(client, channel.Guild, x)).ToImmutableArray(); | return result.Threads.Select(x => RestThreadChannel.Create(client, channel.Guild, x)).ToImmutableArray(); | ||||
} | } | ||||
@@ -179,7 +179,7 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc cref="IGuildChannel.GetActiveThreadsAsync(RequestOptions)"/> | /// <inheritdoc cref="IGuildChannel.GetActiveThreadsAsync(RequestOptions)"/> | ||||
public Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null) | ||||
=> ThreadHelper.GetActiveThreadsAsync(this, Discord, options); | |||||
=> ThreadHelper.GetActiveThreadsInChannelAsync(Guild, this, Discord, options); | |||||
/// <inheritdoc cref="IGuildChannel.GetPublicArchivedThreadsAsync(int?, DateTimeOffset?, RequestOptions)"/> | /// <inheritdoc cref="IGuildChannel.GetPublicArchivedThreadsAsync(int?, DateTimeOffset?, RequestOptions)"/> | ||||
public Task<IReadOnlyCollection<RestThreadChannel>> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) | public Task<IReadOnlyCollection<RestThreadChannel>> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) | ||||