I am trying to make a post request to the following endpoint:
`https://discord.com/api/v9/invites/${link}`
But, i keep getting the following response:
{
captcha_key: [ 'captcha-required' ],
captcha_sitekey: '4c672d35-0701-42b2-88c3-78380b0db560',
captcha_service: 'hcaptcha'
}
What i am trying to do is to write a script where i can join a discord server from a provided discord server invite link.
Below is the function I am using to make a request.
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 seems to be made but, how do I bypass this capctha. I checked headers, they seem to be ok to me. How do I get the user to join a guild using discord api?
Thank you for help.