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.