Skip to content

Commit

Permalink
fix: Client#generateInvite resolving permissions incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewdcario committed Apr 19, 2018
1 parent 7c0b617 commit c387e96
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,20 +391,15 @@ class Client extends EventEmitter {
/**
* Generates a link that can be used to invite the bot to a guild.
* <warn>This is only available when using a bot account.</warn>
* @param {PermissionResolvable[]|number} [permissions] Permissions to request
* @param {PermissionResolvable|PermissionResolvable[]} [permissions] Permissions to request
* @returns {Promise<string>}
* @example
* client.generateInvite(['SEND_MESSAGES', 'MANAGE_GUILD', 'MENTION_EVERYONE'])
* .then(link => {
* console.log(`Generated bot invite link: ${link}`);
* });
* .then(link => console.log(`Generated bot invite link: ${link}`))
* .catch(console.error);
*/
generateInvite(permissions) {
if (permissions) {
if (permissions instanceof Array) permissions = Permissions.resolve(permissions);
} else {
permissions = 0;
}
permissions = typeof permissions === 'undefined' ? 0 : Permissions.resolve(permissions);
return this.fetchApplication().then(application =>
`https://discordapp.com/oauth2/authorize?client_id=${application.id}&permissions=${permissions}&scope=bot`
);
Expand Down

0 comments on commit c387e96

Please # to comment.