diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 2f7aaf5c2..37556069f 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -413,17 +413,13 @@ class RESTMethods { } putGuildMember(guild, user, options) { + options.access_token = options.accessToken; if (options.roles) { - var roles = options.roles; + const 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); } diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 99b0b6012..a0a4a65ce 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -330,20 +330,15 @@ class Guild { } /** - * 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|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 + * Adds a user to the guild using OAuth2. Requires the `CREATE_INSTANT_INVITE` permission. + * @param {UserResolvable} user User to add to the guild + * @param {Object} options Options for the addition + * @param {string} options.accessToken An OAuth2 access token for the user with the `guilds.join` scope granted to the + * bot's application + * @param {string} [options.nick] Nickname to give the member + * @param {Collection|Role[]|Snowflake[]} [options.roles] Roles to add to the member + * @param {boolean} [options.mute] Whether the member should be muted + * @param {boolean} [options.deaf] Whether the member should be deafened * @returns {Promise} */ addMember(user, options) {