From 91dd34927755775b50339d995e939c92258359a3 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:27:57 +0100 Subject: [PATCH 01/10] feat: app authorization links and tags for v13 --- src/structures/ClientApplication.js | 28 ++++++++++++++++++++++++++++ typings/index.d.ts | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 6ad83464b9a6..47f23a89004f 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. @@ -13,6 +20,27 @@ class ClientApplication extends Application { constructor(client, data) { super(client, data); + 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(), + }; + } + + if ('custom_install_url' in data) { + /** + * This application's custom installation URL + * @type {?string} + */ + this.customInstallURL = data.custom_install_url; + } + /** * The application command manager for this application * @type {ApplicationCommandManager} diff --git a/typings/index.d.ts b/typings/index.d.ts index de4e3f486586..77a245d4521c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -603,6 +603,9 @@ export class ClientApplication extends Application { public commands: ApplicationCommandManager; public cover: string | null; public flags: Readonly; + public tags?: [string, string?, string?, string?, string?]; + public installParams?: ClientApplicationInstallParams; + public customInstallURL?: string; public owner: User | Team | null; public readonly partial: boolean; public rpcOrigins: string[]; @@ -3409,6 +3412,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; From 645c3725e3ff27ac94dde8eb91534ee6f6af3916 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:55:21 +0100 Subject: [PATCH 02/10] chore: no longer in the constructor --- src/structures/ClientApplication.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 47f23a89004f..1266ff0215d9 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -19,6 +19,15 @@ const Permissions = require('../util/Permissions'); class ClientApplication extends Application { constructor(client, data) { super(client, data); + /** + * The application command manager for this application + * @type {ApplicationCommandManager} + */ + this.commands = new ApplicationCommandManager(this.client); + } + + _patch(data) { + super._patch(data); this.tags = data.tags ?? []; @@ -41,16 +50,6 @@ class ClientApplication extends Application { this.customInstallURL = data.custom_install_url; } - /** - * The application command manager for this application - * @type {ApplicationCommandManager} - */ - this.commands = new ApplicationCommandManager(this.client); - } - - _patch(data) { - super._patch(data); - if ('flags' in data) { /** * The flags this application has From 7f1136202fecc69b5b9dfd4e29e0cea6cf40e2c5 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:13:51 +0100 Subject: [PATCH 03/10] chore: revert random newline removal --- src/structures/ClientApplication.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 1266ff0215d9..87aa775ff1b1 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -19,6 +19,7 @@ const Permissions = require('../util/Permissions'); class ClientApplication extends Application { constructor(client, data) { super(client, data); + /** * The application command manager for this application * @type {ApplicationCommandManager} From a90af689dd5b3b5de8f47eb25cff8f5a4c990826 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Wed, 30 Mar 2022 00:14:55 +0100 Subject: [PATCH 04/10] docs: document tags --- src/structures/ClientApplication.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 87aa775ff1b1..ce6838e0ed9f 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -30,6 +30,10 @@ 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) { From 8ae2fecd8d75a2909ec1bf319cc5bcae209cc105 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Wed, 30 Mar 2022 00:18:19 +0100 Subject: [PATCH 05/10] chore: fix intendation --- src/structures/ClientApplication.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index ce6838e0ed9f..1882bdb6c9b1 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -30,10 +30,10 @@ class ClientApplication extends Application { _patch(data) { super._patch(data); - ​    ​/** - ​     * The tags this application has (max of 5) - ​     * ​@type​ {string[]} - ​     */ + ​   /** + ​    * The tags this application has (max of 5) + ​    * ​@type​ {string[]} + ​    */ this.tags = data.tags ?? []; if ('install_params' in data) { From 9fe34299a2f5c931c32f8e12b9d3fb2e78200b96 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Wed, 30 Mar 2022 00:20:54 +0100 Subject: [PATCH 06/10] chore: try to delete weird invisible character --- src/structures/ClientApplication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 1882bdb6c9b1..113d468e08e4 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -30,7 +30,7 @@ class ClientApplication extends Application { _patch(data) { super._patch(data); - ​   /** +   /** ​    * The tags this application has (max of 5) ​    * ​@type​ {string[]} ​    */ From 671cd0d6accb1d6c9a235ddd67f43eb7324113d2 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Wed, 30 Mar 2022 00:26:25 +0100 Subject: [PATCH 07/10] chore: fix intendation attempt 2 --- src/structures/ClientApplication.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 113d468e08e4..8bfe9e6533bc 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -30,10 +30,10 @@ class ClientApplication extends Application { _patch(data) { super._patch(data); -   /** - ​    * The tags this application has (max of 5) - ​    * ​@type​ {string[]} - ​    */ + /** + * The tags this application has (max of 5) + * ​@type​ {string[]} + */ this.tags = data.tags ?? []; if ('install_params' in data) { From c905cbb80a8344f3a9c90056d72748349bc8a46a Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Wed, 30 Mar 2022 00:29:34 +0100 Subject: [PATCH 08/10] chore: i think it should work now --- src/structures/ClientApplication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 8bfe9e6533bc..40a59b43b357 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -32,7 +32,7 @@ class ClientApplication extends Application { /** * The tags this application has (max of 5) - * ​@type​ {string[]} + * @type {string[]} */ this.tags = data.tags ?? []; From 20a3b868719a3252855e60ebc035dd5d74f6c4b1 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Tue, 5 Apr 2022 18:07:19 +0100 Subject: [PATCH 09/10] chore: update types to match v14 pr --- typings/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 77a245d4521c..d7f6b58ad9a3 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -603,9 +603,9 @@ export class ClientApplication extends Application { public commands: ApplicationCommandManager; public cover: string | null; public flags: Readonly; - public tags?: [string, string?, string?, string?, string?]; - public installParams?: ClientApplicationInstallParams; - public customInstallURL?: string; + public tags: string[]; + public installParams: ClientApplicationInstallParams | null; + public customInstallURL: string | null; public owner: User | Team | null; public readonly partial: boolean; public rpcOrigins: string[]; From b9bcb018a011c44f32c8c1a8b5fe0abf9ea82eec Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Tue, 5 Apr 2022 18:09:19 +0100 Subject: [PATCH 10/10] chore: update to match v14 pr --- src/structures/ClientApplication.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 40a59b43b357..601314ab55f1 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -45,6 +45,8 @@ class ClientApplication extends Application { scopes: data.install_params.scopes, permissions: new Permissions(data.install_params.permissions).freeze(), }; + } else { + this.installParams ??= null; } if ('custom_install_url' in data) { @@ -53,6 +55,8 @@ class ClientApplication extends Application { * @type {?string} */ this.customInstallURL = data.custom_install_url; + } else { + this.customInstallURL = null; } if ('flags' in data) {