mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
add an invite generator (#993)
* add an invite generator * `number |= null` is safe, so we can simplify this * Update Client.js * aaaaaa
This commit is contained in:
@@ -343,6 +343,29 @@ class Client extends EventEmitter {
|
||||
return this.rest.methods.getMyApplication();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an invite link for your bot
|
||||
* @param {Array|number} [permissions] An array of permissions to request
|
||||
* @returns {Promise<string>} The invite link
|
||||
* @example
|
||||
* client.generateInvite(['SEND_MESSAGES', 'MANAGE_GUILD', 'MENTION_EVERYONE'])
|
||||
* .then(link => {
|
||||
* console.log(link);
|
||||
* });
|
||||
*/
|
||||
generateInvite(permissions) {
|
||||
if (permissions) {
|
||||
if (permissions instanceof Array) {
|
||||
permissions = this.resolver.resolvePermissions(permissions);
|
||||
}
|
||||
} else {
|
||||
permissions = 0;
|
||||
}
|
||||
return this.fetchApplication().then(application =>
|
||||
`https://discordapp.com/oauth2/authorize?client_id=${application.id}&permissions=${permissions}&scope=bot`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a timeout that will be automatically cancelled if the client is destroyed.
|
||||
* @param {Function} fn Function to execute
|
||||
|
||||
Reference in New Issue
Block a user