discord-net/Discord.Net

[Bug]: When creating a post in a forum thread where tags are required, it fails even if you have a tag

ZakFahey opened this issue · 3 comments

Check The Docs

  • I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • I double checked that I have the required intents.

Description

I have a forum channel with the "Require people to select tags when posting" setting enabled. When my bot tries to create a post in that channel, I get the error The channel <channel name> requires posts to have at least one tag.

Also, I'm looking at the places in the stack trace, at

Preconditions.AtLeast(tagIds?.Length ?? 0, 1, nameof(tagIds), $"The channel {channel.Name} requires posts to have at least one tag.");

and

async Task<IThreadChannel> 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)

and

=> ThreadHelper.CreatePostAsync(this, Discord, title, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags, tags?.Select(tag => tag.Id).ToArray());

but the code all looks like it should work. Very strange.

I'll also point out that when the tag requirement is removed, the post will be created successfully, and it will have the correct tags.

Version

3.9.0

One thing I thought was that somehow I'm on the wrong version of the library. Just today I upgraded from version 3.8.1 because that version didn't have the tags parameter in CreatePostAsync, so I thought that maybe after updating the Nuget package that my build scripts somehow didn't copy the new DLLs to the right place. I have, however, ruled that out and confirmed that all the Discord.Net related DLLs show a last modified date of December 23rd.

Working Version

No response

Logs

System.ArgumentException: The channel game-design requires posts to have at least one tag.
   at Discord.Rest.ThreadHelper.CreatePostAsync(IForumChannel channel, BaseDiscordClient client, String title, ThreadArchiveDuration archiveDuration, Nullable`1 slowmode, String text, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags, UInt64[] tagIds)
   at Discord.WebSocket.SocketForumChannel.Discord.IForumChannel.CreatePostAsync(String title, ThreadArchiveDuration archiveDuration, Nullable`1 slowmode, String text, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags, ForumTag[] tags)

Sample

IForumChannel channel = ...; // Fetch the channel
var tags = channel.Tags.Where(tag => tag.Name == "Some tag").ToArray();
Console.WriteLine(tags.Length); // Confirmed that this outputs 1
await channel.CreatePostAsync("This is a test", text: "This is a forum post", tags: tags);

Packages

None

The PR with fix ( #2546 ) was merged after the 3.9.0 was released.
you could build the library yourself or wait for the new release

Oh, that's good to hear. ETA on when the next release will come?

csmir commented

Soon:tm: