From 4ec6c166aeff8498f16d293ae1cd088a9fd5c408 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Sun, 28 Nov 2021 16:56:50 -0400 Subject: [PATCH] Add not supported exception on news channels when creating threads, #296 --- src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs | 8 ++++++++ src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs | 2 +- .../Entities/Channels/SocketNewsChannel.cs | 8 ++++++++ .../Entities/Channels/SocketTextChannel.cs | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs index fad3358dc..224ee6191 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs @@ -25,5 +25,13 @@ 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/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index 57de0eb45..f97c536c8 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -270,7 +270,7 @@ namespace Discord.Rest /// /// A task that represents the asynchronous create operation. The task result contains a /// - public async Task CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, + public virtual async Task CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) { var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options); diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs index 944dd2d7f..38d5f8a99 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs @@ -35,5 +35,13 @@ 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"); } } diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs index aea1bfda5..8dc8e9844 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs @@ -112,7 +112,7 @@ namespace Discord.WebSocket /// /// A task that represents the asynchronous create operation. The task result contains a /// - public async Task CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, + public virtual async Task CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) { var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options);