Webhooks in forums

I tried to send webhook in thread channel, which is created in forum, but got this: DiscordAPIError[220001]: Webhooks posted to forum channels must have a thread_name or thread_id So, how i can specify thread_id for webhook?
const forum = await c.channels.fetch(channelId)
const webhook = await forum.guild.fetchWebhooks().then(webhooks => webhooks.find(webhook => webhook.channelId === channelId))
if (forum) {
const thread = forum.threads.cache.find(thread => thread.name.includes(author.id))
if (thread) {
if (webhook) webhook.send({ content: `**${author.username} (${author.id}):** ${message}` })
else thread.send({ content: `**${author.username} (${author.id}):** ${message}` })
}
const forum = await c.channels.fetch(channelId)
const webhook = await forum.guild.fetchWebhooks().then(webhooks => webhooks.find(webhook => webhook.channelId === channelId))
if (forum) {
const thread = forum.threads.cache.find(thread => thread.name.includes(author.id))
if (thread) {
if (webhook) webhook.send({ content: `**${author.username} (${author.id}):** ${message}` })
else thread.send({ content: `**${author.username} (${author.id}):** ${message}` })
}
5 Replies
d.js docs
d.js docs2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
조아오
조아오2y ago
Your webhook body need to have one of the two properties listed on the error
d.js docs
d.js docs2y ago
discord Webhook: Execute Webhook read more
조아오
조아오2y ago
Read more here
d.js docs
d.js docs2y ago
Documentation suggestion for @anthonyvault:method Webhook#send() Sends a message with this webhook.