mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
feat(Application): application flags (#5147)
Co-authored-by: SpaceEEC <spaceeec@yahoo.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const Team = require('./Team');
|
||||
const Application = require('./interfaces/Application');
|
||||
const ApplicationFlags = require('../util/ApplicationFlags');
|
||||
|
||||
/**
|
||||
* Represents a Client OAuth2 Application.
|
||||
@@ -11,35 +12,64 @@ class ClientApplication extends Application {
|
||||
_patch(data) {
|
||||
super._patch(data);
|
||||
|
||||
/**
|
||||
* The flags this application has
|
||||
* @type {ApplicationFlags}
|
||||
*/
|
||||
this.flags = 'flags' in data ? new ApplicationFlags(data.flags) : this.flags;
|
||||
|
||||
/**
|
||||
* The app's cover image
|
||||
* @type {?string}
|
||||
*/
|
||||
this.cover = data.cover_image || null;
|
||||
this.cover = data.cover_image ?? this.cover ?? null;
|
||||
|
||||
/**
|
||||
* The app's RPC origins, if enabled
|
||||
* @type {string[]}
|
||||
*/
|
||||
this.rpcOrigins = data.rpc_origins || [];
|
||||
this.rpcOrigins = data.rpc_origins ?? this.rpcOrigins ?? [];
|
||||
|
||||
/**
|
||||
* If this app's bot requires a code grant when using the OAuth2 flow
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.botRequireCodeGrant = typeof data.bot_require_code_grant !== 'undefined' ? data.bot_require_code_grant : null;
|
||||
this.botRequireCodeGrant = data.bot_require_code_grant ?? this.botRequireCodeGrant ?? null;
|
||||
|
||||
/**
|
||||
* If this app's bot is public
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.botPublic = typeof data.bot_public !== 'undefined' ? data.bot_public : null;
|
||||
this.botPublic = data.bot_public ?? this.botPublic ?? null;
|
||||
|
||||
/**
|
||||
* The owner of this OAuth application
|
||||
* @type {?User|Team}
|
||||
*/
|
||||
this.owner = data.team ? new Team(this.client, data.team) : data.owner ? this.client.users.add(data.owner) : null;
|
||||
this.owner = data.team
|
||||
? new Team(this.client, data.team)
|
||||
: data.owner
|
||||
? this.client.users.add(data.owner)
|
||||
: this.owner ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this application is partial
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get partial() {
|
||||
return !this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains this application from Discord.
|
||||
* @returns {Promise<ClientApplication>}
|
||||
*/
|
||||
async fetch() {
|
||||
const app = await this.client.api.oauth2.applications('@me').get();
|
||||
this._patch(app);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user