chore: make requested changes (#7000)

This commit is contained in:
Suneet Tipirneni
2022-04-05 06:22:56 -04:00
committed by GitHub
parent 905a6a1166
commit f88e1ac4be
2 changed files with 44 additions and 0 deletions

View File

@@ -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<PermissionsBitField>} 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

View File

@@ -756,6 +756,9 @@ export class ClientApplication extends Application {
public commands: ApplicationCommandManager;
public cover: string | null;
public flags: Readonly<ApplicationFlagsBitField>;
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<PermissionsBitField>;
}
export type Serialized<T> = T extends symbol | bigint | (() => any)
? never
: T extends number | string | boolean | undefined