mirror of
https://github.com/danbulant/discord.js
synced 2026-06-19 22:51:32 +00:00
Webpack build: fa7d63a10a
This commit is contained in:
parent
9bb44cf0f8
commit
01a53d242d
2 changed files with 40 additions and 4 deletions
|
|
@ -10905,6 +10905,19 @@ class ClientDataResolver {
|
|||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn an array of permissions into a valid discord permission bitfield
|
||||
* @param {Array} permissions An array of permissions as strings or permissions numbers (see resolvePermission)
|
||||
* @returns {number}
|
||||
*/
|
||||
resolvePermissions(permissions) {
|
||||
let bitfield = 0;
|
||||
for (const permission of permissions) {
|
||||
bitfield |= this.resolvePermission(permission);
|
||||
}
|
||||
return bitfield;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that can be resolved to give a string. This can be:
|
||||
* * A string
|
||||
|
|
@ -11517,6 +11530,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
|
||||
|
|
|
|||
8
discord.indev.min.js
vendored
8
discord.indev.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue