Making POST request to discord server in nodejs

0 votes

I'm attempting to send a post to the following endpoint:

`https://discord.com/api/v9/invites/${link}`

However, I continue to receive the same response:

{
  captcha_key: [ 'captcha-required' ],
  captcha_sitekey: '4c672d35-0701-42b2-88c3-78380b0db560',
  captcha_service: 'hcaptcha'
}

What I'm trying to do is create a script that allows me to join a discord server using a specified invite URL.

The function I'm using to make a request is listed below.

const fetch_request = async (link, options) => {
  if (typeof link !== "string") throw new Error("Couldn't fetch");
  return new Promise((res, rej) => {
      fetch(`https://discord.com/api/v9/invites/${link}`, {
          headers: {
              "accept": "*/*",
              "accept-language": "en-US",
              "authorization": "<user_token_here>",
              "content-type": "application/json",
              "sec-fetch-dest": "empty",
              "sec-fetch-mode": "cors",
              "sec-fetch-site": "same-origin",
              "x-discord-locale": "en-US",
              "origin": "https://discord.com",
              referer: `https://discord.com/channels/@me`,
              mode: "cors",
          },
          body: JSON.stringify('{}'),
          method: 'POST'
              
        }).then((response) => {
          if (options.parse) {
              response.json().then((m) => {
                  res(m);
              });
          } else {
              res(response);
          }
      });
  });
}

The request appears to have been made, but how do I get around this capctha? I double-checked the headers and they appear to be in good shape. How can I utilise the Discord API to get a user to join a guild?

Thank you for your assistance.

May 30, 2022 in Node-js by Neha
• 9,020 points
1,237 views

1 answer to this question.

0 votes
You'll need to solve the captchas; I recommend using a service like 2captchas or another comparable alternative; they're cheap and easy to set up.

It's incredibly simple; all you have to do is obtain "captcha key" and include it in your next request.
answered May 30, 2022 by Vaani
• 7,070 points

Related Questions In Node-js

0 votes
1 answer

How to pass text/plain content in axios POST request in nodejs?

var config = { ...READ MORE

answered Jun 14, 2022 in Node-js by Neha
• 9,020 points
6,066 views
0 votes
1 answer

How to get path from the request in nodejs?

Hello @kartik, Try this out: var http = require('http'); var ...READ MORE

answered Oct 14, 2020 in Node-js by Niroj
• 82,840 points
4,532 views
0 votes
1 answer

Extend SchemaDirectiveVisitor To Use Apollo Server Schema Directives in NodeJS

Because the ApolloServer class lacks a SchemaDirectiveVisitor ...READ MORE

answered Jun 17, 2022 in Node-js by Neha
• 9,020 points
863 views
0 votes
1 answer

How to process POST data in Node.js?

Hello @kartik, You can use the querystring module: var qs = ...READ MORE

answered Jul 9, 2020 in Node-js by Niroj
• 82,840 points
2,628 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,936 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,461 views
0 votes
1 answer

Start script missing error when running npm start

It seems that there is an undefined ...READ MORE

answered Feb 10, 2022 in Java by Soham
• 9,710 points
4,452 views
0 votes
1 answer

Installing angularjs with NPM and NODEJS brings an error in ubuntu 16.04

Rename your angular folder to angular-test or ...READ MORE

answered May 30, 2022 in Node-js by Vaani
• 7,070 points
1,333 views
0 votes
1 answer

Extending a middy middleware function in nodejs

Your pseudocode comes close to being correct. ...READ MORE

answered May 30, 2022 in Node-js by Vaani
• 7,070 points
1,067 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP