catto.js 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/User.js +53 -23
- package/package.json +1 -1
package/User.js
CHANGED
|
@@ -2,44 +2,64 @@ var request = require("./request");
|
|
|
2
2
|
var Application = require("./Application");
|
|
3
3
|
module.exports = class {
|
|
4
4
|
constructor(options, bot) {
|
|
5
|
+
if (options.global_name) {
|
|
6
|
+
options.globalName = options.global_name;
|
|
7
|
+
}
|
|
8
|
+
if (options.public_flags) {
|
|
9
|
+
options.publicFlags = options.public_flags;
|
|
10
|
+
}
|
|
11
|
+
if (options.banner_color) {
|
|
12
|
+
options.bannerColor = options.banner_color;
|
|
13
|
+
}
|
|
14
|
+
if (options.accent_color) {
|
|
15
|
+
options.accentColor = options.accent_color;
|
|
16
|
+
}
|
|
17
|
+
if (options.mfa_enabled) {
|
|
18
|
+
options.mfaEnabled = options.mfa_enabled;
|
|
19
|
+
}
|
|
20
|
+
if (options.premium_type) {
|
|
21
|
+
options.premiumType = options.premium_type;
|
|
22
|
+
}
|
|
23
|
+
if (options.avatar_decoration_data) {
|
|
24
|
+
options.avatarDecorationData = options.avatar_decoration_data;
|
|
25
|
+
}
|
|
5
26
|
this.options = Object.assign({
|
|
6
27
|
"id": "",
|
|
28
|
+
"globalName": "",
|
|
7
29
|
"username": "",
|
|
8
30
|
"avatar": "",
|
|
9
31
|
"discriminator": "",
|
|
10
|
-
"
|
|
32
|
+
"publicFlags": 0,
|
|
11
33
|
"flags": 0,
|
|
12
34
|
"banner": "",
|
|
13
|
-
"banner_color": "",
|
|
14
35
|
"bannerColor": "",
|
|
15
|
-
"accent_color": 0,
|
|
16
36
|
"accentColor": 0,
|
|
17
37
|
"locale": "",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
38
|
+
"mfaEnabled": !1,
|
|
39
|
+
"premiumType": 0,
|
|
20
40
|
"email": "",
|
|
21
41
|
"verified": !1,
|
|
22
42
|
"bot": !1,
|
|
23
|
-
"system": !1
|
|
43
|
+
"system": !1,
|
|
44
|
+
"avatarDecorationData": {}
|
|
24
45
|
}, options || {});
|
|
25
46
|
this.bot = bot;
|
|
26
|
-
if (this.isBot) {
|
|
27
|
-
request.get({
|
|
28
|
-
"url": `https://discord.com/api/v${(this.bot ? (this.bot.client.rest.version ? this.bot.client.rest.version.toString() : "10") : "10")}/oauth2/applications/${this.id}/rpc`,
|
|
29
|
-
"headers": {
|
|
30
|
-
"Authorization": `Bot ${this.bot.client.token}`
|
|
31
|
-
}
|
|
32
|
-
}).then(application => {
|
|
33
|
-
this.application = new Application(application.body);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
47
|
}
|
|
37
48
|
get id() {
|
|
38
49
|
return this.options.id;
|
|
39
50
|
}
|
|
51
|
+
get globalName() {
|
|
52
|
+
return this.options.globalName;
|
|
53
|
+
}
|
|
40
54
|
get name() {
|
|
41
55
|
return this.options.username;
|
|
42
56
|
}
|
|
57
|
+
get decorationHash() {
|
|
58
|
+
return (this.options.avatarDecorationData ? this.options.avatarDecorationData.asset : null);
|
|
59
|
+
}
|
|
60
|
+
get decoration() {
|
|
61
|
+
return `https://cdn.discordapp.com/avatar-decoration-presets/${this.decorationHash}.png`;
|
|
62
|
+
}
|
|
43
63
|
get avatarHash() {
|
|
44
64
|
return this.options.avatar;
|
|
45
65
|
}
|
|
@@ -101,7 +121,7 @@ module.exports = class {
|
|
|
101
121
|
return this.options.banner;
|
|
102
122
|
}
|
|
103
123
|
get bannerColor() {
|
|
104
|
-
return this.options.
|
|
124
|
+
return this.options.bannerColor;
|
|
105
125
|
}
|
|
106
126
|
get banner() {
|
|
107
127
|
var banneru = this.bannerHash;
|
|
@@ -115,7 +135,7 @@ module.exports = class {
|
|
|
115
135
|
return banneru;
|
|
116
136
|
}
|
|
117
137
|
get accentColor() {
|
|
118
|
-
return this.options.
|
|
138
|
+
return this.options.accentColor;
|
|
119
139
|
}
|
|
120
140
|
get lang() {
|
|
121
141
|
return this.options.locale;
|
|
@@ -124,19 +144,19 @@ module.exports = class {
|
|
|
124
144
|
return (this.lang == "ru");
|
|
125
145
|
}
|
|
126
146
|
get is2FAEnabled() {
|
|
127
|
-
return this.options.
|
|
147
|
+
return this.options.mfaEnabled;
|
|
128
148
|
}
|
|
129
149
|
get hasNitro() {
|
|
130
|
-
return (this.isBot || this.options.
|
|
150
|
+
return (this.isBot || this.options.premiumType > 0);
|
|
131
151
|
}
|
|
132
152
|
get hasNitroClassic() {
|
|
133
|
-
return (this.options.
|
|
153
|
+
return (this.options.premiumType == 1);
|
|
134
154
|
}
|
|
135
155
|
get hasNitroBoost() {
|
|
136
|
-
return (this.isBot || this.options.
|
|
156
|
+
return (this.isBot || this.options.premiumType == 2);
|
|
137
157
|
}
|
|
138
158
|
get hasNitroBasic() {
|
|
139
|
-
return (this.options.
|
|
159
|
+
return (this.options.premiumType == 3);
|
|
140
160
|
}
|
|
141
161
|
get email() {
|
|
142
162
|
return this.options.email;
|
|
@@ -153,4 +173,14 @@ module.exports = class {
|
|
|
153
173
|
get isSystem() {
|
|
154
174
|
return this.options.system;
|
|
155
175
|
}
|
|
176
|
+
async requestApplication() {
|
|
177
|
+
if (this.isBot) {
|
|
178
|
+
this.application = new Application((await request.get({
|
|
179
|
+
"url": `https://discord.com/api/v${(this.bot ? (this.bot.client.rest.version ? this.bot.client.rest.version.toString() : "10") : "10")}/oauth2/applications/${this.id}/rpc`,
|
|
180
|
+
"headers": {
|
|
181
|
+
"Authorization": `Bot ${this.bot.client.token}`
|
|
182
|
+
}
|
|
183
|
+
})).body);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
156
186
|
};
|