From ca6c9bcff77648b9b3b8f55d192c11b0cb001599 Mon Sep 17 00:00:00 2001 From: Robin Laevaert <33598142+RobinLaevaert@users.noreply.github.com> Date: Sun, 2 Nov 2025 14:50:27 +0100 Subject: [PATCH] Get Archived thread calls on text channels (#3198) * Get Archived thread calls on text channels * Throw not supported exceptions on Thread&Voice channels * Extract interface * Should probably also change these * Move to regions --- .../Entities/Channels/IForumChannel.cs | 50 +-------------- .../Entities/Channels/ITextChannel.cs | 13 +--- .../Channels/IThreadContainerChannel.cs | 61 +++++++++++++++++++ .../Entities/Channels/RestForumChannel.cs | 51 ++++++++-------- .../Entities/Channels/RestTextChannel.cs | 34 ++++++++--- .../Entities/Channels/RestThreadChannel.cs | 24 ++++++++ .../Entities/Channels/RestVoiceChannel.cs | 24 ++++++++ .../Entities/Channels/SocketForumChannel.cs | 52 ++++++++-------- .../Entities/Channels/SocketTextChannel.cs | 33 +++++++--- .../Entities/Channels/SocketThreadChannel.cs | 24 ++++++++ .../Entities/Channels/SocketVoiceChannel.cs | 24 +++++++- .../MockedEntities/MockedTextChannel.cs | 3 + .../MockedEntities/MockedVoiceChannel.cs | 3 + 13 files changed, 269 insertions(+), 127 deletions(-) create mode 100644 src/Discord.Net.Core/Entities/Channels/IThreadContainerChannel.cs diff --git a/src/Discord.Net.Core/Entities/Channels/IForumChannel.cs b/src/Discord.Net.Core/Entities/Channels/IForumChannel.cs index dda6a6c3..1bb49adb 100644 --- a/src/Discord.Net.Core/Entities/Channels/IForumChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IForumChannel.cs @@ -10,7 +10,7 @@ namespace Discord /// /// Represents a forum channel in a guild that can create posts. /// - public interface IForumChannel : IMentionable, INestedChannel, IIntegrationChannel + public interface IForumChannel : IMentionable, INestedChannel, IIntegrationChannel, IThreadContainerChannel { /// /// Gets a value that indicates whether the channel is NSFW. @@ -226,53 +226,5 @@ namespace Discord int? slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null); - /// - /// Gets a collection of active threads within this forum channel. - /// - /// The options to be used when sending the request. - /// - /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains - /// a collection of active threads. - /// - Task> GetActiveThreadsAsync(RequestOptions options = null); - - /// - /// Gets a collection of publicly archived threads within this forum channel. - /// - /// The optional limit of how many to get. - /// The optional date to return threads created before this timestamp. - /// The options to be used when sending the request. - /// - /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains - /// a collection of publicly archived threads. - /// - Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null); - - /// - /// Gets a collection of privately archived threads within this forum channel. - /// - /// - /// The bot requires the permission in order to execute this request. - /// - /// The optional limit of how many to get. - /// The optional date to return threads created before this timestamp. - /// The options to be used when sending the request. - /// - /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains - /// a collection of privately archived threads. - /// - Task> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null); - - /// - /// Gets a collection of privately archived threads that the current bot has joined within this forum channel. - /// - /// The optional limit of how many to get. - /// The optional date to return threads created before this timestamp. - /// The options to be used when sending the request. - /// - /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains - /// a collection of privately archived threads. - /// - Task> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null); } } diff --git a/src/Discord.Net.Core/Entities/Channels/ITextChannel.cs b/src/Discord.Net.Core/Entities/Channels/ITextChannel.cs index 54956f14..f3b18205 100644 --- a/src/Discord.Net.Core/Entities/Channels/ITextChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/ITextChannel.cs @@ -8,7 +8,7 @@ namespace Discord /// /// Represents a generic channel in a guild that can send and receive messages. /// - public interface ITextChannel : IMessageChannel, IMentionable, INestedChannel, IIntegrationChannel + public interface ITextChannel : IMessageChannel, IMentionable, INestedChannel, IIntegrationChannel, IThreadContainerChannel { /// /// Gets a value that indicates whether the channel is NSFW. @@ -125,7 +125,7 @@ namespace Discord /// The duration on which this thread archives after. /// /// Note: Options and - /// are only available for guilds that are boosted. You can check in the to see if the + /// are only available for guilds that are boosted. You can check in the to see if the /// guild has the THREE_DAY_THREAD_ARCHIVE and SEVEN_DAY_THREAD_ARCHIVE. /// /// @@ -139,14 +139,5 @@ namespace Discord Task CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null); - /// - /// Gets a collection of active threads within this channel. - /// - /// The options to be used when sending the request. - /// - /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains - /// a collection of active threads. - /// - Task> GetActiveThreadsAsync(RequestOptions options = null); } } diff --git a/src/Discord.Net.Core/Entities/Channels/IThreadContainerChannel.cs b/src/Discord.Net.Core/Entities/Channels/IThreadContainerChannel.cs new file mode 100644 index 00000000..63efd03f --- /dev/null +++ b/src/Discord.Net.Core/Entities/Channels/IThreadContainerChannel.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Discord +{ + /// + /// Represents a channel that can contain and query threads. + /// + public interface IThreadContainerChannel + { + /// + /// Gets a collection of active threads within this channel. + /// + /// The options to be used when sending the request. + /// + /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains + /// a collection of active threads. + /// + Task> GetActiveThreadsAsync(RequestOptions options = null); + + /// + /// Gets a collection of publicly archived threads within this channel. + /// + /// The optional limit of how many to get. + /// The optional date to return threads created before this timestamp. + /// The options to be used when sending the request. + /// + /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains + /// a collection of publicly archived threads. + /// + Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null); + + /// + /// Gets a collection of privately archived threads within this channel. + /// + /// + /// The bot requires the permission in order to execute this request. + /// + /// The optional limit of how many to get. + /// The optional date to return threads created before this timestamp. + /// The options to be used when sending the request. + /// + /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains + /// a collection of privately archived threads. + /// + Task> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null); + + /// + /// Gets a collection of privately archived threads that the current bot has joined within this channel. + /// + /// The optional limit of how many to get. + /// The optional date to return threads created before this timestamp. + /// The options to be used when sending the request. + /// + /// A task that represents an asynchronous get operation for retrieving the threads. The task result contains + /// a collection of privately archived threads. + /// + Task> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null); + } +} diff --git a/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs index 1ea32c07..db3dda20 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs @@ -138,22 +138,6 @@ namespace Discord.Rest MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null) => ThreadHelper.CreatePostAsync(this, Discord, title, attachments, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags, tags?.Select(tag => tag.Id).ToArray()); - /// - public Task> GetActiveThreadsAsync(RequestOptions options = null) - => ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options); - - /// - public Task> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) - => ThreadHelper.GetJoinedPrivateArchivedThreadsAsync(this, Discord, limit, before, options); - - /// - public Task> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) - => ThreadHelper.GetPrivateArchivedThreadsAsync(this, Discord, limit, before, options); - - /// - public Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) - => ThreadHelper.GetPublicArchivedThreadsAsync(this, Discord, limit, before, options); - /// public Task CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null) => ChannelHelper.CreateWebhookAsync(this, Discord, name, avatar, options); @@ -167,14 +151,6 @@ namespace Discord.Rest => ChannelHelper.GetWebhooksAsync(this, Discord, options); #region IForumChannel - async Task> IForumChannel.GetActiveThreadsAsync(RequestOptions options) - => await GetActiveThreadsAsync(options).ConfigureAwait(false); - async Task> IForumChannel.GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) - => await GetPublicArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); - async Task> IForumChannel.GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) - => await GetPrivateArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); - async Task> IForumChannel.GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) - => await GetJoinedPrivateArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); async Task IForumChannel.CreatePostAsync(string title, ThreadArchiveDuration archiveDuration, int? slowmode, string text, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags, ForumTag[] tags) => await CreatePostAsync(title, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags, tags).ConfigureAwait(false); async Task IForumChannel.CreatePostWithFileAsync(string title, string filePath, ThreadArchiveDuration archiveDuration, int? slowmode, string text, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags, ForumTag[] tags) @@ -230,5 +206,32 @@ namespace Discord.Rest #endregion + #region IThreadContainerChannel + /// + public Task> GetActiveThreadsAsync(RequestOptions options = null) + => ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options); + + /// + public Task> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) + => ThreadHelper.GetJoinedPrivateArchivedThreadsAsync(this, Discord, limit, before, options); + + /// + public Task> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) + => ThreadHelper.GetPrivateArchivedThreadsAsync(this, Discord, limit, before, options); + + /// + public Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) + => ThreadHelper.GetPublicArchivedThreadsAsync(this, Discord, limit, before, options); + + async Task> IThreadContainerChannel.GetActiveThreadsAsync(RequestOptions options) + => await GetActiveThreadsAsync(options).ConfigureAwait(false); + async Task> IThreadContainerChannel.GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetPublicArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); + async Task> IThreadContainerChannel.GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetPrivateArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); + async Task> IThreadContainerChannel.GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetJoinedPrivateArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); + #endregion + } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index 88aabdab..5d34e612 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -287,10 +287,6 @@ namespace Discord.Rest /// public Task SyncPermissionsAsync(RequestOptions options = null) => ChannelHelper.SyncPermissionsAsync(this, Discord, options); - - /// - public virtual Task> GetActiveThreadsAsync(RequestOptions options = null) - => ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options); #endregion #region Invites @@ -329,10 +325,6 @@ namespace Discord.Rest async Task ITextChannel.CreateThreadAsync(string name, ThreadType type, ThreadArchiveDuration autoArchiveDuration, IMessage message, bool? invitable, int? slowmode, RequestOptions options) => await CreateThreadAsync(name, type, autoArchiveDuration, message, invitable, slowmode, options); - - /// - async Task> ITextChannel.GetActiveThreadsAsync(RequestOptions options) - => await GetActiveThreadsAsync(options); #endregion #region IMessageChannel @@ -453,5 +445,31 @@ namespace Discord.Rest return null; } #endregion + + #region IThreadContainerChannel + /// + public virtual Task> GetActiveThreadsAsync(RequestOptions options = null) + => ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options); + /// + public virtual Task> GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => ThreadHelper.GetPublicArchivedThreadsAsync(this, Discord, limit, before, options); + /// + public virtual Task> GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => ThreadHelper.GetPrivateArchivedThreadsAsync(this, Discord, limit, before, options); + /// + public virtual Task> GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => ThreadHelper.GetJoinedPrivateArchivedThreadsAsync(this, Discord, limit, before, options); + + + /// + async Task> IThreadContainerChannel.GetActiveThreadsAsync(RequestOptions options) + => await GetActiveThreadsAsync(options); + async Task> IThreadContainerChannel.GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetPublicArchivedThreadsAsync(limit, before, options); + async Task> IThreadContainerChannel.GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetPrivateArchivedThreadsAsync(limit, before, options); + async Task> IThreadContainerChannel.GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetJoinedPrivateArchivedThreadsAsync(limit, before, options); + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs index 053b5fdf..37eaedaf 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs @@ -262,5 +262,29 @@ namespace Discord.Rest /// This method is not supported in threads. public override Task> GetActiveThreadsAsync(RequestOptions options = null) => throw new NotSupportedException("This method is not supported in threads."); + + /// + /// + /// This method is not supported in threads. + /// + /// This method is not supported in threads. + public override Task> GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("This method is not supported in threads."); + + /// + /// + /// This method is not supported in threads. + /// + /// This method is not supported in threads. + public override Task> GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("This method is not supported in threads."); + + /// + /// + /// This method is not supported in threads. + /// + /// This method is not supported in threads. + public override Task> GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("This method is not supported in threads."); } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs index 73dacf5b..6faaa364 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs @@ -83,6 +83,30 @@ namespace Discord.Rest public override Task> GetActiveThreadsAsync(RequestOptions options = null) => throw new NotSupportedException("Threads are not supported in voice channels"); + /// + /// + /// Threads are not supported in voice channels + /// + /// Threads are not supported in voice channels + public override Task> GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("Threads are not supported in voice channels"); + + /// + /// + /// Threads are not supported in voice channels + /// + /// Threads are not supported in voice channels + public override Task> GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("Threads are not supported in voice channels"); + + /// + /// + /// Threads are not supported in voice channels. + /// + /// Threads are not supported in voice channels + public override Task> GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("Threads are not supported in voice channels"); + #endregion diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs index ef696bd2..1e893a02 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs @@ -140,22 +140,6 @@ namespace Discord.WebSocket MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null) => ThreadHelper.CreatePostAsync(this, Discord, title, attachments, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags, tags?.Select(tag => tag.Id).ToArray()); - /// - public Task> GetActiveThreadsAsync(RequestOptions options = null) - => ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options); - - /// - public Task> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) - => ThreadHelper.GetJoinedPrivateArchivedThreadsAsync(this, Discord, limit, before, options); - - /// - public Task> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) - => ThreadHelper.GetPrivateArchivedThreadsAsync(this, Discord, limit, before, options); - - /// - public Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) - => ThreadHelper.GetPublicArchivedThreadsAsync(this, Discord, limit, before, options); - #region Webhooks /// @@ -186,15 +170,6 @@ namespace Discord.WebSocket #endregion #region IForumChannel - async Task> IForumChannel.GetActiveThreadsAsync(RequestOptions options) - => await GetActiveThreadsAsync(options).ConfigureAwait(false); - async Task> IForumChannel.GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) - => await GetPublicArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); - async Task> IForumChannel.GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) - => await GetPrivateArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); - async Task> IForumChannel.GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) - => await GetJoinedPrivateArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); - async Task IForumChannel.CreatePostAsync(string title, ThreadArchiveDuration archiveDuration, int? slowmode, string text, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags, ForumTag[] tags) => await CreatePostAsync(title, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags, tags).ConfigureAwait(false); async Task IForumChannel.CreatePostWithFileAsync(string title, string filePath, ThreadArchiveDuration archiveDuration, int? slowmode, string text, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags, ForumTag[] tags) @@ -231,5 +206,32 @@ namespace Discord.WebSocket public virtual Task SyncPermissionsAsync(RequestOptions options = null) => ChannelHelper.SyncPermissionsAsync(this, Discord, options); #endregion + + #region IThreadContainerChannel + /// + public Task> GetActiveThreadsAsync(RequestOptions options = null) + => ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options); + + /// + public Task> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) + => ThreadHelper.GetJoinedPrivateArchivedThreadsAsync(this, Discord, limit, before, options); + + /// + public Task> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) + => ThreadHelper.GetPrivateArchivedThreadsAsync(this, Discord, limit, before, options); + + /// + public Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) + => ThreadHelper.GetPublicArchivedThreadsAsync(this, Discord, limit, before, options); + + async Task> IThreadContainerChannel.GetActiveThreadsAsync(RequestOptions options) + => await GetActiveThreadsAsync(options).ConfigureAwait(false); + async Task> IThreadContainerChannel.GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetPublicArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); + async Task> IThreadContainerChannel.GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetPrivateArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); + async Task> IThreadContainerChannel.GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetJoinedPrivateArchivedThreadsAsync(limit, before, options).ConfigureAwait(false); + #endregion } } diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs index cba49835..e91d4a78 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs @@ -129,11 +129,6 @@ namespace Discord.WebSocket return thread; } - - /// - public virtual Task> GetActiveThreadsAsync(RequestOptions options = null) - => ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options); - #endregion #region Messages @@ -386,9 +381,6 @@ namespace Discord.WebSocket #region ITextChannel async Task ITextChannel.CreateThreadAsync(string name, ThreadType type, ThreadArchiveDuration autoArchiveDuration, IMessage message, bool? invitable, int? slowmode, RequestOptions options) => await CreateThreadAsync(name, type, autoArchiveDuration, message, invitable, slowmode, options); - /// - async Task> ITextChannel.GetActiveThreadsAsync(RequestOptions options) - => await GetActiveThreadsAsync(options); #endregion #region IGuildChannel @@ -468,6 +460,31 @@ namespace Discord.WebSocket #endregion + #region IThreadContainerChannel + /// + public virtual Task> GetActiveThreadsAsync(RequestOptions options = null) + => ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options); + /// + public virtual Task> GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => ThreadHelper.GetPublicArchivedThreadsAsync(this, Discord, limit, before, options); + /// + public virtual Task> GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => ThreadHelper.GetPrivateArchivedThreadsAsync(this, Discord, limit, before, options); + /// + public virtual Task> GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => ThreadHelper.GetJoinedPrivateArchivedThreadsAsync(this, Discord, limit, before, options); + + /// + async Task> IThreadContainerChannel.GetActiveThreadsAsync(RequestOptions options) + => await GetActiveThreadsAsync(options); + async Task> IThreadContainerChannel.GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetPublicArchivedThreadsAsync(limit, before, options); + async Task> IThreadContainerChannel.GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetPrivateArchivedThreadsAsync(limit, before, options); + async Task> IThreadContainerChannel.GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => await GetJoinedPrivateArchivedThreadsAsync(limit, before, options); + #endregion + #region INestedChannel /// Task INestedChannel.GetCategoryAsync(CacheMode mode, RequestOptions options) diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs index 5f476d89..39a51b01 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs @@ -387,6 +387,30 @@ namespace Discord.WebSocket public override Task> GetActiveThreadsAsync(RequestOptions options = null) => throw new NotSupportedException("This method is not supported in threads."); + /// + /// + /// This method is not supported in threads. + /// + /// This method is not supported in threads. + public override Task> GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("This method is not supported in threads."); + + /// + /// + /// This method is not supported in threads. + /// + /// This method is not supported in threads. + public override Task> GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("This method is not supported in threads."); + + /// + /// + /// This method is not supported in threads. + /// + /// This method is not supported in threads. + public override Task> GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("This method is not supported in threads."); + string IChannel.Name => Name; } } diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs index 4711b3db..df68b393 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs @@ -99,7 +99,7 @@ namespace Discord.WebSocket /// public Task ModifyAsync(Action func, RequestOptions options = null) => Guild.ModifyAudioAsync(Id, func, options); - + /// public override SocketGuildUser GetUser(ulong id) @@ -121,7 +121,27 @@ namespace Discord.WebSocket /// Threads are not supported in voice channels public override Task> GetActiveThreadsAsync(RequestOptions options = null) => throw new NotSupportedException("Threads are not supported in voice channels"); - + /// + /// + /// Threads are not supported in voice channels + /// + /// Threads are not supported in voice channels + public override Task> GetPublicArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("Threads are not supported in voice channels"); + /// + /// + /// Threads are not supported in voice channels + /// + /// Threads are not supported in voice channels + public override Task> GetPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("Threads are not supported in voice channels"); + /// + /// + /// Threads are not supported in voice channels. + /// + /// Threads are not supported in voice channels + public override Task> GetJoinedPrivateArchivedThreadsAsync(int? limit, DateTimeOffset? before, RequestOptions options) + => throw new NotSupportedException("Threads are not supported in voice channels"); #endregion private string DebuggerDisplay => $"{Name} ({Id}, Voice)"; diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs index 52d54e25..4208a9cd 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs @@ -224,5 +224,8 @@ namespace Discord public Task CreateInviteToApplicationAsync(DefaultApplications application, int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => throw new NotImplementedException(); public Task CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) => throw new NotImplementedException(); public Task> GetActiveThreadsAsync(RequestOptions options = null) => throw new NotImplementedException(); + public Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) => throw new NotImplementedException(); + public Task> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) => throw new NotImplementedException(); + public Task> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) => throw new NotImplementedException(); } } diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs index 9b557771..5566a80c 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs @@ -27,6 +27,9 @@ namespace Discord public Task CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) => throw new NotImplementedException(); public Task> GetActiveThreadsAsync(RequestOptions options = null) => throw new NotImplementedException(); + public Task> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) => throw new NotImplementedException(); + public Task> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) => throw new NotImplementedException(); + public Task> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null) => throw new NotImplementedException(); public ulong? CategoryId => throw new NotImplementedException();