@@ -356,21 +356,37 @@ class Client extends BaseClient {
356356
357357 /**
358358 * Generates a link that can be used to invite the bot to a guild.
359- * @param {PermissionResolvable } [permissions ] Permissions to request
359+ * @param {InviteGenerationOptions| PermissionResolvable } [options ] Permissions to request
360360 * @returns {Promise<string> }
361361 * @example
362- * client.generateInvite(['SEND_MESSAGES', 'MANAGE_GUILD', 'MENTION_EVERYONE'])
362+ * client.generateInvite({
363+ * permissions: ['SEND_MESSAGES', 'MANAGE_GUILD', 'MENTION_EVERYONE'],
364+ * })
363365 * .then(link => console.log(`Generated bot invite link: ${link}`))
364366 * .catch(console.error);
365367 */
366- async generateInvite ( permissions ) {
367- permissions = Permissions . resolve ( permissions ) ;
368+ async generateInvite ( options = { } ) {
369+ if ( Array . isArray ( options ) || [ 'string' , 'number' ] . includes ( typeof options ) || options instanceof Permissions ) {
370+ process . emitWarning (
371+ 'Client#generateInvite: Generate invite with an options object instead of a PermissionResolvable' ,
372+ 'DeprecationWarning' ,
373+ ) ;
374+ options = { permissions : options } ;
375+ }
368376 const application = await this . fetchApplication ( ) ;
369377 const query = new URLSearchParams ( {
370378 client_id : application . id ,
371- permissions : permissions ,
379+ permissions : Permissions . resolve ( options . permissions ) ,
372380 scope : 'bot' ,
373381 } ) ;
382+ if ( typeof options . disableGuildSelect === 'boolean' ) {
383+ query . set ( 'disable_guild_select' , options . disableGuildSelect . toString ( ) ) ;
384+ }
385+ if ( typeof options . guild !== 'undefined' ) {
386+ const guildID = this . guilds . resolveID ( options . guild ) ;
387+ if ( ! guildID ) throw new TypeError ( 'INVALID_TYPE' , 'options.guild' , 'GuildResolvable' ) ;
388+ query . set ( 'guild_id' , guildID ) ;
389+ }
374390 return `${ this . options . http . api } ${ this . api . oauth2 . authorize } ?${ query } ` ;
375391 }
376392
@@ -443,6 +459,14 @@ class Client extends BaseClient {
443459
444460module . exports = Client ;
445461
462+ /**
463+ * Options for {@link Client#generateInvite}.
464+ * @typedef {Object } InviteGenerationOptions
465+ * @property {PermissionResolvable } [permissions] Permissions to request
466+ * @property {GuildResolvable } [guild] Guild to preselect
467+ * @property {boolean } [disableGuildSelect] Whether to disable the guild selection
468+ */
469+
446470/**
447471 * Emitted for general warnings.
448472 * @event Client#warn
0 commit comments