From 6965063f2429a4fde3bb95b98c8af585603992e5 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:42:54 +0000 Subject: [PATCH 1/2] refactor(IntegrationApplication): move common properties to Application --- .../src/structures/ClientApplication.js | 20 -------- .../src/structures/IntegrationApplication.js | 50 ------------------- .../src/structures/interfaces/Application.js | 50 +++++++++++++++++++ packages/discord.js/typings/index.d.ts | 10 ++-- 4 files changed, 55 insertions(+), 75 deletions(-) diff --git a/packages/discord.js/src/structures/ClientApplication.js b/packages/discord.js/src/structures/ClientApplication.js index 9e1492b42b16..b3c944f955cb 100644 --- a/packages/discord.js/src/structures/ClientApplication.js +++ b/packages/discord.js/src/structures/ClientApplication.js @@ -173,26 +173,6 @@ class ClientApplication extends Application { this.guildId ??= null; } - if ('cover_image' in data) { - /** - * The hash of the application's cover image - * @type {?string} - */ - this.cover = data.cover_image; - } else { - this.cover ??= null; - } - - if ('rpc_origins' in data) { - /** - * The application's RPC origins, if enabled - * @type {string[]} - */ - this.rpcOrigins = data.rpc_origins; - } else { - this.rpcOrigins ??= []; - } - if ('bot_require_code_grant' in data) { /** * If this application's bot requires a code grant when using the OAuth2 flow diff --git a/packages/discord.js/src/structures/IntegrationApplication.js b/packages/discord.js/src/structures/IntegrationApplication.js index 49850084880e..29b2c12c4c46 100644 --- a/packages/discord.js/src/structures/IntegrationApplication.js +++ b/packages/discord.js/src/structures/IntegrationApplication.js @@ -20,36 +20,6 @@ class IntegrationApplication extends Application { this.bot ??= null; } - if ('terms_of_service_url' in data) { - /** - * The URL of the application's terms of service - * @type {?string} - */ - this.termsOfServiceURL = data.terms_of_service_url; - } else { - this.termsOfServiceURL ??= null; - } - - if ('privacy_policy_url' in data) { - /** - * The URL of the application's privacy policy - * @type {?string} - */ - this.privacyPolicyURL = data.privacy_policy_url; - } else { - this.privacyPolicyURL ??= null; - } - - if ('rpc_origins' in data) { - /** - * The Array of RPC origin URLs - * @type {string[]} - */ - this.rpcOrigins = data.rpc_origins; - } else { - this.rpcOrigins ??= []; - } - if ('hook' in data) { /** * Whether the application can be default hooked by the client @@ -59,26 +29,6 @@ class IntegrationApplication extends Application { } else { this.hook ??= null; } - - if ('cover_image' in data) { - /** - * The hash of the application's cover image - * @type {?string} - */ - this.cover = data.cover_image; - } else { - this.cover ??= null; - } - - if ('verify_key' in data) { - /** - * The hex-encoded key for verification in interactions and the GameSDK's GetTicket - * @type {?string} - */ - this.verifyKey = data.verify_key; - } else { - this.verifyKey ??= null; - } } } diff --git a/packages/discord.js/src/structures/interfaces/Application.js b/packages/discord.js/src/structures/interfaces/Application.js index 5e81465e28bd..67302fb7a7f3 100644 --- a/packages/discord.js/src/structures/interfaces/Application.js +++ b/packages/discord.js/src/structures/interfaces/Application.js @@ -50,6 +50,56 @@ class Application extends Base { } else { this.icon ??= null; } + + if ('terms_of_service_url' in data) { + /** + * The URL of the application's terms of service + * @type {?string} + */ + this.termsOfServiceURL = data.terms_of_service_url; + } else { + this.termsOfServiceURL ??= null; + } + + if ('privacy_policy_url' in data) { + /** + * The URL of the application's privacy policy + * @type {?string} + */ + this.privacyPolicyURL = data.privacy_policy_url; + } else { + this.privacyPolicyURL ??= null; + } + + if ('rpc_origins' in data) { + /** + * The application's RPC origins, if enabled + * @type {string[]} + */ + this.rpcOrigins = data.rpc_origins; + } else { + this.rpcOrigins ??= []; + } + + if ('cover_image' in data) { + /** + * The hash of the application's cover image + * @type {?string} + */ + this.cover = data.cover_image; + } else { + this.cover ??= null; + } + + if ('verify_key' in data) { + /** + * The hex-encoded key for verification in interactions and the GameSDK's GetTicket + * @type {?string} + */ + this.verifyKey = data.verify_key; + } else { + this.verifyKey ??= null; + } } /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 812431f7c290..6a889ebd68ef 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -412,6 +412,11 @@ export abstract class Application extends Base { public icon: string | null; public id: Snowflake; public name: string | null; + public termsOfServiceURL: string | null; + public privacyPolicyURL: string | null; + public rpcOrigins: string[]; + public cover: string | null; + public verifyKey: string | null; public coverURL(options?: ImageURLOptions): string | null; public iconURL(options?: ImageURLOptions): string | null; public toJSON(): unknown; @@ -1899,12 +1904,7 @@ export class Integration extends Base { export class IntegrationApplication extends Application { private constructor(client: Client, data: RawIntegrationApplicationData); public bot: User | null; - public termsOfServiceURL: string | null; - public privacyPolicyURL: string | null; - public rpcOrigins: string[]; public hook: boolean | null; - public cover: string | null; - public verifyKey: string | null; } export type GatewayIntentsString = keyof typeof GatewayIntentBits; From 839fa785d79d0f18e254adae6d3b0b07a0c83301 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:44:14 +0000 Subject: [PATCH 2/2] fix: remove prop from ClientApplication --- packages/discord.js/typings/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 6a889ebd68ef..04a2642fb1d8 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1076,7 +1076,6 @@ export class ClientApplication extends Application { public subscriptions: SubscriptionManager; public guildId: Snowflake | null; public get guild(): Guild | null; - public cover: string | null; public flags: Readonly; public approximateGuildCount: number | null; public approximateUserInstallCount: number | null; @@ -1088,7 +1087,6 @@ export class ClientApplication extends Application { public get partial(): boolean; public interactionsEndpointURL: string | null; public roleConnectionsVerificationURL: string | null; - public rpcOrigins: string[]; public edit(options: ClientApplicationEditOptions): Promise; public fetch(): Promise; public fetchRoleConnectionMetadataRecords(): Promise;