'Discord webhook post to channel thread

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!



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 circadian