From c9e38792ff2c28480a9ae1bec5f3b65e578da75b Mon Sep 17 00:00:00 2001 From: quin lynch Date: Sun, 28 Nov 2021 17:03:09 -0400 Subject: [PATCH] Revert thread block for news channel. Add check for news channel Co-Authored-By: Nova Fox --- src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs | 8 -------- src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs | 3 +++ .../Entities/Channels/SocketNewsChannel.cs | 7 ------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs index 224ee6191..fad3358dc 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs @@ -25,13 +25,5 @@ namespace Discord.Rest return entity; } public override int SlowModeInterval => throw new NotSupportedException("News channels do not support Slow Mode."); - - /// - /// News channels do not support thread creation with bots. - /// - /// - /// - public override 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 NotSupportedException("Cannot create threads in News channels"); } } diff --git a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs index 917410f98..e0074ecff 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs @@ -21,6 +21,9 @@ namespace Discord.Rest if (type == ThreadType.PrivateThread && !features.HasFeature(GuildFeature.PrivateThreads)) throw new ArgumentException($"The guild {channel.Guild.Name} does not have the PRIVATE_THREADS feature!", nameof(type)); + if (channel is INewsChannel && type != ThreadType.NewsThread) + throw new ArgumentException($"{nameof(type)} must be a {ThreadType.NewsThread} in News channels"); + var args = new StartThreadParams { Name = name, diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs index 38d5f8a99..eed8f9374 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs @@ -36,12 +36,5 @@ namespace Discord.WebSocket public override int SlowModeInterval => throw new NotSupportedException("News channels do not support Slow Mode."); - /// - /// News channels do not support thread creation with bots. - /// - /// - /// - public override 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 NotSupportedException("Cannot create threads in News channels"); } }