Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

[Bug]: ForumTagBuilder builds ForumTagProperties instead of ForumTags

Open yort5 opened this issue 1 year ago • 2 comments

Check The Docs

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

Verify Issue Source

  • [X] I verified the issue was caused by Discord.Net.

Check your intents

  • [X] I double checked that I have the required intents.

Description

I am trying to programmatically create and attach a new tag when I'm creating a Forum post. The CreatePostAsync method optionally takes and array of FormTags, however there does not seem to be any way to create a ForumTag object. Searching through the docs and the code, most references are internal, and the method that seems like it would be the one to use - ForumTagBuilder - returns a ForumTagProperties object instead of a ForumTag. Shouldn't this provide us with a ForumTag? Or at least be renamed, but it would be nice to have some way to create a ForumTag.

Version

3.10.0

Working Version

No response

Logs

No logs, unless you want to see the exception when I try to cast a ForumTagProperties object to a ForumTag.

Sample

List<ForumTag> forumTags = new List<ForumTag>();
ForumTagBuilder builder = new ForumTagBuilder().WithName(rulesForumId);
// need to get to ForumTag
forumTags.Add(...);

forumChannel.CreatePostAsync(threadTitle, text: messageString, embed: channelEmbed.Build(), tags: forumTags.ToArray());

Packages

None

yort5 avatar Apr 06 '23 16:04 yort5

ForumTagBuilder is used only to create/modify tags in a forum channel And since tags are predefined in a channel - it kinda makes sense that it not possible to just create ones.

So to get tags for the post - do some searching in IForumChannel.Tags collection

I agree with your point on naming, but changing it would be a breaking change, so it'd only be possible in v4.

Misha-133 avatar Apr 06 '23 16:04 Misha-133

That makes sense. I was probably trying to use Tags for a little more than they are currently intended. I'll adjust my approach, and ignore the naming for now. :)

yort5 avatar Apr 06 '23 16:04 yort5