Skip to content

Commit

Permalink
feat: app authorization links and tags for v13 (#7731)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Apr 14, 2022
1 parent 6c56132 commit 9e4a900
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/structures/ClientApplication.js
Expand Up @@ -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>} permissions The permissions this bot will request upon joining
*/

/**
* Represents a Client OAuth2 Application.
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions typings/index.d.ts
Expand Up @@ -634,6 +634,9 @@ export class ClientApplication extends Application {
public commands: ApplicationCommandManager;
public cover: string | null;
public flags: Readonly<ApplicationFlags>;
public tags: string[];
public installParams: ClientApplicationInstallParams | null;
public customInstallURL: string | null;
public owner: User | Team | null;
public readonly partial: boolean;
public rpcOrigins: string[];
Expand Down Expand Up @@ -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<Permissions>;
}

export interface APIErrors {
UNKNOWN_ACCOUNT: 10001;
UNKNOWN_APPLICATION: 10002;
Expand Down

0 comments on commit 9e4a900

Please sign in to comment.