Discord webhook post to channel thread
Asked Answered
S

1

7

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!

Saltigrade answered 8/1, 2022 at 11:2 Comment(0)
S
9

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.

Setaceous answered 2/5, 2022 at 16:31 Comment(1)
Thanks for your post. I had seen that it was possible to send the thread ID in the parameters, but using a service like IFTTT I can't see how that can be achieved. Any ideas?Saltigrade

© 2022 - 2024 — McMap. All rights reserved.