From 9e4a900e6d540ad611675ec54ba35e2b9da984dd Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Thu, 14 Apr 2022 12:47:11 +0200 Subject: [PATCH] feat: app authorization links and tags for v13 (#7731) --- src/structures/ClientApplication.js | 36 +++++++++++++++++++++++++++++ typings/index.d.ts | 8 +++++++ 2 files changed, 44 insertions(+) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 6ad83464b9a6..601314ab55f1 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -4,6 +4,13 @@ const Team = require('./Team'); const Application = require('./interfaces/Application'); const ApplicationCommandManager = require('../managers/ApplicationCommandManager'); const ApplicationFlags = require('../util/ApplicationFlags'); +const Permissions = require('../util/Permissions'); + +/** + * @typedef {Object} ClientApplicationInstallParams + * @property {InviteScope[]} 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. @@ -23,6 +30,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 Permissions(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/typings/index.d.ts b/typings/index.d.ts index 738296ea624e..fbb85d02eb16 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -634,6 +634,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 readonly partial: boolean; public rpcOrigins: string[]; @@ -3568,6 +3571,11 @@ export type AllowedThreadTypeForNewsChannel = 'GUILD_NEWS_THREAD' | 10; export type AllowedThreadTypeForTextChannel = 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 11 | 12; +export interface ClientApplicationInstallParams { + scopes: InviteScope[]; + permissions: Readonly; +} + export interface APIErrors { UNKNOWN_ACCOUNT: 10001; UNKNOWN_APPLICATION: 10002;