Browse Source

Fix `DiscordRestClient.GetChannelAsync` not getting forum channel

pull/2469/head
Misha133 2 years ago
parent
commit
a4e07a3f50
2 changed files with 14 additions and 4 deletions
  1. +5
    -2
      src/Discord.Net.Rest/Entities/Channels/RestChannel.cs
  2. +9
    -2
      src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs

+ 5
- 2
src/Discord.Net.Rest/Entities/Channels/RestChannel.cs View File

@@ -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),


+ 9
- 2
src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs View File

@@ -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();
}

/// <inheritdoc/>
public async Task ModifyAsync(Action<ForumChannelProperties> func, RequestOptions options = null)
{
var model = await ForumHelper.ModifyAsync(this, Discord, func, options);
Update(model);
}

/// <inheritdoc cref="IForumChannel.CreatePostAsync(string, ThreadArchiveDuration, int?, string, Embed, RequestOptions, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
public Task<RestThreadChannel> 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);


Loading…
Cancel
Save