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:
Mike
2017-02-08 22:04:39 +01:00
committed by Amish Shah
parent 2518a0f7e2
commit dd6dd6fb59
2 changed files with 38 additions and 0 deletions

View File

@@ -331,6 +331,28 @@ class Guild {
return this.client.rest.methods.fetchVoiceRegions(this.id);
}
/**
* The data for a role
* @typedef {Object} AddGuildMemberOptions
* @property {string} accessToken An oauth2 access token granted with the guilds.join to the bot's application
* for the user you want to add to the guild
* @property {string} [nick] Value to set users nickname to
* @property {Collection<Snowflake, Role>|Role[]|string[]} [roles] The roles or role IDs to add
* @property {boolean} [mute] If the user is muted
* @property {boolean} [deaf] If the user is deafened
*/
/**
* Add a user to this guild using OAuth2
* @param {UserResolvable|string} user The user or ID of the user to add to guild
* @param {AddGuildMemberOptions} options Options object containing the access_token
* @returns {Promise<GuildMember>}
*/
addMember(user, options) {
if (this.members.has(user.id)) return Promise.resolve(this.members.get(user.id));
return this.client.rest.methods.putGuildMember(this, user, options);
}
/**
* Fetch a single guild member from a user.
* @param {UserResolvable} user The user to fetch the member for