mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Added support for adding users to guild 2 (#1179)
* Added support for adding users to guild
added RESTMethods#AddGuildMemberOptions and Guild#addMember with typedef
AddGuildMemberOptions to be able to add user to guild as a member
through `PUT/guilds/{guild.id}/members/{user.id}`
https://discordapp.com/developers/docs/resources/guild#add-guild-member
* fixing lint errors
* Changes based on discussion
* Changes based on discussion 2
* Changes based on discussion 3
Yay! More changes.
This commit is contained in:
@@ -377,6 +377,22 @@ class RESTMethods {
|
||||
return this.rest.makeRequest('get', Constants.Endpoints.channelMessage(channel.id, messageID), true);
|
||||
}
|
||||
|
||||
putGuildMember(guild, user, options) {
|
||||
if (options.roles) {
|
||||
var roles = options.roles;
|
||||
if (roles instanceof Collection || (roles instanceof Array && roles[0] instanceof Role)) {
|
||||
options.roles = roles.map(role => role.id);
|
||||
}
|
||||
}
|
||||
if (options.accessToken) {
|
||||
options.access_token = options.accessToken;
|
||||
} else {
|
||||
return Promise.reject(new Error('OAuth2 access token was not specified.'));
|
||||
}
|
||||
return this.rest.makeRequest('put', Constants.Endpoints.guildMember(guild.id, user.id), true, options)
|
||||
.then(data => this.client.actions.GuildMemberGet.handle(guild, data).member);
|
||||
}
|
||||
|
||||
getGuildMember(guild, user, cache) {
|
||||
return this.rest.makeRequest('get', Constants.Endpoints.guildMember(guild.id, user.id), true).then(data => {
|
||||
if (cache) {
|
||||
|
||||
Reference in New Issue
Block a user