Can incoming webhooks work directly with the app/bot?

Hi. Is there a way to have a discord incoming webhook work directly with a bot or do you have to work through incoming messages, check if webhook message, etc.? I mean it would be great to send a JSON payload to the bot this way. My goal is to have an incoming webhook trigger some actions in the installed server. discord.js: 14.13.0 nodejs: 18.16.0
5 Replies
d.js toolkit
d.js toolkit9mo 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 staff
grass
grass9mo ago
you can use a web server
brettski
brettski9mo ago
Thank you, though I am not sure I am following. Use a web server where?
mahakadema
mahakadema9mo ago
You can host a web server on your bot. (Let's say your bot runs on 234.56.1.89) Then you can send a POST request to https://234.56.1.89/whatever and receive that data on your bot. That's not really djs related anymore tho, rather it's implementing webhooks on ur own. (look up "nodejs how to host web server and handle requests", u can also use libraries such as Express, which make that part a lot easier) As for using the webhooks discord provides (with https://discord.com) u can only do that by reading the messages that get send to discord channels as a result. (Ur client never sees the data before that, as it's handled by the server at discord.com)
brettski
brettski9mo ago
Thanks, for the details and confirming my options.