I am trying to make a put request to the Discord API, in order to add the user to a guild. Here is my code :
app.get("/api/auth/joinguild", async (req: Request, res: Response) => {
try {
const body = new url.URLSearchParams({
"access_token": `${accessToken}`
})
const guild_id = "HIDDEN";
const user_id = "HIDDEN";
const botToken = "HIDDEN"
const response = await axios.put(`https://discord.com/api/v10/guilds/${guild_id}/members/${user_id}`,
body.toString(),
{
headers: {
Authorization: `Bot ${botToken}`,
'Content-Type': 'application/json',
},
});
res.send(await response.data)
} catch (err) {
res.send(await err);
}
});
The accessToken I have is correct since I can use it to call endpoints such as https://discord.com/api/v10/users/@me