I'm setting up a api connection. I have already an OAuth-authentication and a bot for my app. Now I want to make changes on discord Guild Member Role.
I make a PATCH and it return an 204. According to discord: "Returns a 204 empty response on success". But the don't get an update. No changes at Role.
Here is my "PATCH function":
function patchGuildMemberRole( userId, callback) {
var API_ModifyGuildMember_URL = 'https://discordapp.com/api/guilds/500000000000000000/members/' + userId;
data = {
"roles": ["600000000000000000", "600000000000000000"]
};
header = {
'method' : 'PATCH',
'Authorization': 'Bot' + ' ' + 'XXXXXXXXXXXXXXXXXXXXXXXXXX',
'followRedirects' : true,
'Content-Type': 'application/x-www-form-urlencoded',
'payload' : data
};
var result = UrlFetchApp.fetch(API_ModifyGuildMember_URL, {headers: header});
console.log("result");
console.log(result);
if (result.getResponseCode() == 204 || result.getResponseCode() == 200) {
var params = JSON.parse(result.getContentText());
return callback(params);
} else {
return callback(error('API fetch error'));
}
}
Here is my Response: "params":
{
"nick": "Kevin - Kevin",
"user": {
"username": "Kevin",
"discriminator": "6666",
"id": "500000000000000000", "avatar": "zzzzzzzzzzzzzz80acd5bb1a005"
},
"roles": ["500000000000000000"],
"premium_since": null,
"deaf": false,
"mute": false,
"joined_at": "2016-04-00T00:00:00.000000+00:00"
}
We want to update the roles to : ["600000000000000000", "600000000000000000"]
but we only have the old roles: ["500000000000000000"]