diff --git a/packages/discord.js/src/structures/ClientApplication.js b/packages/discord.js/src/structures/ClientApplication.js index f77cf0402..811147cd4 100644 --- a/packages/discord.js/src/structures/ClientApplication.js +++ b/packages/discord.js/src/structures/ClientApplication.js @@ -5,6 +5,13 @@ const Team = require('./Team'); const Application = require('./interfaces/Application'); const ApplicationCommandManager = require('../managers/ApplicationCommandManager'); const ApplicationFlagsBitField = require('../util/ApplicationFlagsBitField'); +const PermissionsBitField = require('../util/PermissionsBitField'); + +/** + * @typedef {Object} ClientApplicationInstallParams + * @property {OAuth2Scopes[]} scopes The scopes to add the application to the server with + * @property {Readonly} permissions The permissions this bot will request upon joining + */ /** * Represents a Client OAuth2 Application. @@ -24,6 +31,35 @@ class ClientApplication extends Application { _patch(data) { super._patch(data); + /** + * The tags this application has (max of 5) + * @type {string[]} + */ + this.tags = data.tags ?? []; + + if ('install_params' in data) { + /** + * Settings for this application's default in-app authorization + * @type {?ClientApplicationInstallParams} + */ + this.installParams = { + scopes: data.install_params.scopes, + permissions: new PermissionsBitField(data.install_params.permissions).freeze(), + }; + } else { + this.installParams ??= null; + } + + if ('custom_install_url' in data) { + /** + * This application's custom installation URL + * @type {?string} + */ + this.customInstallURL = data.custom_install_url; + } else { + this.customInstallURL = null; + } + if ('flags' in data) { /** * The flags this application has diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index dd8575c84..a4b08d3ad 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -756,6 +756,9 @@ export class ClientApplication extends Application { public commands: ApplicationCommandManager; public cover: string | null; public flags: Readonly; + public tags: string[]; + public installParams: ClientApplicationInstallParams | null; + public customInstallURL: string | null; public owner: User | Team | null; public get partial(): boolean; public rpcOrigins: string[]; @@ -5261,6 +5264,11 @@ export interface WelcomeScreenEditData { welcomeChannels?: WelcomeChannelData[]; } +export interface ClientApplicationInstallParams { + scopes: OAuth2Scopes[]; + permissions: Readonly; +} + export type Serialized = T extends symbol | bigint | (() => any) ? never : T extends number | string | boolean | undefined