Discord webhook post to channel thread

Viewed 1492

How does one use Discord webhooks to post to a channel thread, not the channel itself? For example, I have a text channel called videos in which are a number of threads: A, B, C etc. I want to use a webhook to automatically post URLs to new youtube videos in particular threads, but not directly into the channel.

Is it possible to somehow modify the Discord webhook URL with the thread ID?

https://discord.com/developers/docs/resources/webhook

Is it something that can be added into the JSON file?

Please help!

1 Answers

You can pass a thread_id query param to add a comment to the thread you want. For example:

fetch(`https://discord.com/api/webhooks/${webhook.id}/${webhook.token}?thread_id=${thread.id}`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ content: 'This is a comment under a thread!', })
});

Just make sure the webhook ID and token are for the channel that the thread is in.

Related