-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
ClientApplication.js
75 lines (63 loc) · 1.57 KB
/
ClientApplication.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
const Team = require('./Team');
const Application = require('./interfaces/Application');
/**
* Represents a Client OAuth2 Application.
* @extends {Application}
*/
class ClientApplication extends Application {
constructor(client, data) {
super(client, data);
/**
* The flags this application has
* @type {number}
*/
this.flags = data.flags;
}
_patch(data) {
super._patch(data);
/**
* The app's cover image
* @type {?string}
*/
this.cover = data.cover_image ?? null;
/**
* The app's RPC origins, if enabled
* @type {string[]}
*/
this.rpcOrigins = data.rpc_origins ?? [];
/**
* If this app's bot requires a code grant when using the OAuth2 flow
* @type {?boolean}
*/
this.botRequireCodeGrant = data.bot_require_code_grant ?? null;
/**
* If this app's bot is public
* @type {?boolean}
*/
this.botPublic = data.bot_public ?? 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;
}
/**
* Whether this application is partial
* @type {boolean}
* @readonly
*/
get partial() {
return this.name === null;
}
/**
* 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;
}
}
module.exports = ClientApplication;