support new guild member role endpoints for cleaner role updates (#901)

* support new roles endpoints

* use promise chaining

* properties man

* Update RESTMethods.js

* Update RESTMethods.js

* Update RESTMethods.js

* Update RESTMethods.js
This commit is contained in:
Gus Caplan
2016-12-02 22:46:55 -06:00
committed by Schuyler Cebulskie
parent 8b7ef0c850
commit 638e51a18c
3 changed files with 22 additions and 2 deletions

View File

@@ -328,6 +328,23 @@ class RESTMethods {
);
}
addMemberRole(member, role) {
return this.rest.makeRequest('put', Constants.Endpoints.guildMemberRole(member.guild.id, member.id, role.id))
.then(() => {
if (!member._roles.includes(role.id)) member._roles.push(role.id);
return member;
});
}
removeMemberRole(member, role) {
return this.rest.makeRequest('delete', Constants.Endpoints.guildMemberRole(member.guild.id, member.id, role.id))
.then(() => {
const index = member._roles.indexOf(role.id);
if (index >= 0) member._roles.splice(index, 1);
return member;
});
}
sendTyping(channelID) {
return this.rest.makeRequest('post', `${Constants.Endpoints.channel(channelID)}/typing`, true);
}