Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: app authorization links and tags for v13 #7731

Merged
merged 10 commits into from Apr 14, 2022
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 ?? [];
SuperchupuDev marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -603,6 +603,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 @@ -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<Permissions>;
}

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