How would I go about getting the currently applied tags in a Forums channel?

I tries this and kept getting Failed to change thread tags: TypeError: Cannot read properties of undefined (reading 'fetch')
try {
if (member.roles.cache.has(botRoleId)) {
return;
}

const currentTags = await thread.tags.fetch();
const currentTagIds = currentTags.map(tag => tag.id);

if (member.roles.cache.has(supportRoleId)) {
if (!currentTagIds.includes(staffResponseTag)) {
await thread.setArchived(false);
await thread.setAppliedTags([staffResponseTag]);
}
} else {
if (!currentTagIds.includes(creatorResponseTag)) {
await thread.setArchived(false);
await thread.setAppliedTags([creatorResponseTag]);
}
}
} catch (error) {
console.error('Failed to change thread tags:', error);
}
}
try {
if (member.roles.cache.has(botRoleId)) {
return;
}

const currentTags = await thread.tags.fetch();
const currentTagIds = currentTags.map(tag => tag.id);

if (member.roles.cache.has(supportRoleId)) {
if (!currentTagIds.includes(staffResponseTag)) {
await thread.setArchived(false);
await thread.setAppliedTags([staffResponseTag]);
}
} else {
if (!currentTagIds.includes(creatorResponseTag)) {
await thread.setArchived(false);
await thread.setAppliedTags([creatorResponseTag]);
}
}
} catch (error) {
console.error('Failed to change thread tags:', error);
}
}
4 Replies
d.js toolkit
d.js toolkit5mo 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! - Marked as resolved by OP
d.js docs
d.js docs5mo ago
property ThreadChannel#appliedTags The tags applied to this thread
duck
duck5mo ago
there's no need to fetch them, they're sent with the thread channel
AthenaRebel
AthenaRebel5mo ago
Oh ok