catto.js 0.4.3 → 0.4.4

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.
Files changed (2) hide show
  1. package/User.js +48 -22
  2. package/package.json +1 -1
package/User.js CHANGED
@@ -2,44 +2,60 @@ 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
+ }
5
23
  this.options = Object.assign({
6
24
  "id": "",
25
+ "globalName": "",
7
26
  "username": "",
8
27
  "avatar": "",
9
28
  "discriminator": "",
10
- "public_flags": 0,
29
+ "publicFlags": 0,
11
30
  "flags": 0,
12
31
  "banner": "",
13
- "banner_color": "",
14
32
  "bannerColor": "",
15
- "accent_color": 0,
16
33
  "accentColor": 0,
17
34
  "locale": "",
18
- "mfa_enabled": !1,
19
- "premium_type": 0,
35
+ "mfaEnabled": !1,
36
+ "premiumType": 0,
20
37
  "email": "",
21
38
  "verified": !1,
22
39
  "bot": !1,
23
40
  "system": !1
24
41
  }, options || {});
25
42
  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
43
  }
37
44
  get id() {
38
45
  return this.options.id;
39
46
  }
47
+ get globalName() {
48
+ return this.options.globalName;
49
+ }
40
50
  get name() {
41
51
  return this.options.username;
42
52
  }
53
+ get decorationHash() {
54
+ return this.options.avatar_decoration_data.asset;
55
+ }
56
+ get decoration() {
57
+ return `https://cdn.discordapp.com/avatar-decoration-presets/${this.decorationHash}.png`;
58
+ }
43
59
  get avatarHash() {
44
60
  return this.options.avatar;
45
61
  }
@@ -101,7 +117,7 @@ module.exports = class {
101
117
  return this.options.banner;
102
118
  }
103
119
  get bannerColor() {
104
- return this.options.banner_color || this.options.bannerColor;
120
+ return this.options.bannerColor;
105
121
  }
106
122
  get banner() {
107
123
  var banneru = this.bannerHash;
@@ -115,7 +131,7 @@ module.exports = class {
115
131
  return banneru;
116
132
  }
117
133
  get accentColor() {
118
- return this.options.accent_color || this.options.accentColor;
134
+ return this.options.accentColor;
119
135
  }
120
136
  get lang() {
121
137
  return this.options.locale;
@@ -124,19 +140,19 @@ module.exports = class {
124
140
  return (this.lang == "ru");
125
141
  }
126
142
  get is2FAEnabled() {
127
- return this.options.mfa_enabled;
143
+ return this.options.mfaEnabled;
128
144
  }
129
145
  get hasNitro() {
130
- return (this.isBot || this.options.premium_type > 0);
146
+ return (this.isBot || this.options.premiumType > 0);
131
147
  }
132
148
  get hasNitroClassic() {
133
- return (this.options.premium_type == 1);
149
+ return (this.options.premiumType == 1);
134
150
  }
135
151
  get hasNitroBoost() {
136
- return (this.isBot || this.options.premium_type == 2);
152
+ return (this.isBot || this.options.premiumType == 2);
137
153
  }
138
154
  get hasNitroBasic() {
139
- return (this.options.premium_type == 3);
155
+ return (this.options.premiumType == 3);
140
156
  }
141
157
  get email() {
142
158
  return this.options.email;
@@ -153,4 +169,14 @@ module.exports = class {
153
169
  get isSystem() {
154
170
  return this.options.system;
155
171
  }
172
+ async requestApplication() {
173
+ if (this.isBot) {
174
+ this.application = new Application((await request.get({
175
+ "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`,
176
+ "headers": {
177
+ "Authorization": `Bot ${this.bot.client.token}`
178
+ }
179
+ })).body);
180
+ }
181
+ }
156
182
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catto.js",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Universal module for everything.",
5
5
  "main": "index.js",
6
6
  "scripts": {