From a4e07a3f50798e6913195fc29375a0d9743271f2 Mon Sep 17 00:00:00 2001 From: Misha133 Date: Tue, 20 Sep 2022 23:33:18 +0300 Subject: [PATCH] Fix `DiscordRestClient.GetChannelAsync` not getting forum channel --- src/Discord.Net.Rest/Entities/Channels/RestChannel.cs | 7 +++++-- .../Entities/Channels/RestForumChannel.cs | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs index c730596c7..3f472c74e 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs @@ -30,13 +30,15 @@ namespace Discord.Rest ChannelType.Stage or ChannelType.NewsThread or ChannelType.PrivateThread or - ChannelType.PublicThread + ChannelType.PublicThread or + ChannelType.Forum => RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model), ChannelType.DM or ChannelType.Group => CreatePrivate(discord, model) as RestChannel, ChannelType.Category => RestCategoryChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model), _ => new RestChannel(discord, model.Id), }; } + internal static RestChannel Create(BaseDiscordClient discord, Model model, IGuild guild) { return model.Type switch @@ -47,7 +49,8 @@ namespace Discord.Rest ChannelType.Stage or ChannelType.NewsThread or ChannelType.PrivateThread or - ChannelType.PublicThread + ChannelType.PublicThread or + ChannelType.Forum => RestGuildChannel.Create(discord, guild, model), ChannelType.DM or ChannelType.Group => CreatePrivate(discord, model) as RestChannel, ChannelType.Category => RestCategoryChannel.Create(discord, guild, model), diff --git a/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs index 03bb276b9..66024d4ed 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs @@ -41,9 +41,9 @@ namespace Discord.Rest } - internal new static RestStageChannel Create(BaseDiscordClient discord, IGuild guild, Model model) + internal new static RestForumChannel Create(BaseDiscordClient discord, IGuild guild, Model model) { - var entity = new RestStageChannel(discord, guild, model.Id); + var entity = new RestForumChannel(discord, guild, model.Id); entity.Update(model); return entity; } @@ -66,6 +66,13 @@ namespace Discord.Rest ).ToImmutableArray(); } + /// + public async Task ModifyAsync(Action func, RequestOptions options = null) + { + var model = await ForumHelper.ModifyAsync(this, Discord, func, options); + Update(model); + } + /// public Task CreatePostAsync(string title, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, 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) => ThreadHelper.CreatePostAsync(this, Discord, title, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags);