Forum tags - Create a new tag if not exists

I try to create a new tags in a forum if the tag exists:
const availableTags: GuildForumTagData[] = allTags.map((tag) => {
return {
id: tag.id,
moderated: tag.moderated,
name: tag.name,
emoji: tag.emoji,
};
});
availableTags.push({
name: "Dice Roll",
emoji: { id: null, name: "🪡" },
});
await forum.setAvailableTags(availableTags);
return availableTags.find(
(tag) => tag.name === "Dice Roll" && tag.emoji?.name === "🪡"
) as GuildForumTagData;
const availableTags: GuildForumTagData[] = allTags.map((tag) => {
return {
id: tag.id,
moderated: tag.moderated,
name: tag.name,
emoji: tag.emoji,
};
});
availableTags.push({
name: "Dice Roll",
emoji: { id: null, name: "🪡" },
});
await forum.setAvailableTags(availableTags);
return availableTags.find(
(tag) => tag.name === "Dice Roll" && tag.emoji?.name === "🪡"
) as GuildForumTagData;
But it seems that the absence of id leads to an error:
Invalid Form Body
applied_tags[0][BASE_TYPE_REQUIRED]: This field is required
Invalid Form Body
applied_tags[0][BASE_TYPE_REQUIRED]: This field is required
But I don't know how to set an ID when creating a new tags?
2 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Mara
Mara2mo ago
Note: At the tags is created, I think it's just that availableTags is different from forum.avalableTags after the setAvailableTags