catto.js 0.4.2 → 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.
- package/Server.js +7 -2
- package/User.js +50 -22
- package/package.json +3 -3
- package/request.js +11 -2
package/Server.js
CHANGED
|
@@ -4,8 +4,13 @@ var expressWs = require("express-ws");
|
|
|
4
4
|
var http = require("http");
|
|
5
5
|
var https = require("https");
|
|
6
6
|
var bodyParser = require("body-parser");
|
|
7
|
-
var urlencodedParser = bodyParser.urlencoded({
|
|
8
|
-
|
|
7
|
+
var urlencodedParser = bodyParser.urlencoded({
|
|
8
|
+
"limit": "50mb",
|
|
9
|
+
"extended": !0
|
|
10
|
+
});
|
|
11
|
+
var jsonParser = bodyParser.json({
|
|
12
|
+
"limit": "50mb"
|
|
13
|
+
});
|
|
9
14
|
var fs = require("fs");
|
|
10
15
|
var path = require("path");
|
|
11
16
|
var session = require("express-session");
|
package/User.js
CHANGED
|
@@ -2,42 +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
|
-
"
|
|
29
|
+
"publicFlags": 0,
|
|
11
30
|
"flags": 0,
|
|
12
31
|
"banner": "",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
32
|
+
"bannerColor": "",
|
|
33
|
+
"accentColor": 0,
|
|
15
34
|
"locale": "",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
35
|
+
"mfaEnabled": !1,
|
|
36
|
+
"premiumType": 0,
|
|
18
37
|
"email": "",
|
|
19
38
|
"verified": !1,
|
|
20
39
|
"bot": !1,
|
|
21
40
|
"system": !1
|
|
22
41
|
}, options || {});
|
|
23
42
|
this.bot = bot;
|
|
24
|
-
if (this.isBot) {
|
|
25
|
-
request.get({
|
|
26
|
-
"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`,
|
|
27
|
-
"headers": {
|
|
28
|
-
"Authorization": `Bot ${this.bot.client.token}`
|
|
29
|
-
}
|
|
30
|
-
}).then(application => {
|
|
31
|
-
this.application = new Application(application.body);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
43
|
}
|
|
35
44
|
get id() {
|
|
36
45
|
return this.options.id;
|
|
37
46
|
}
|
|
47
|
+
get globalName() {
|
|
48
|
+
return this.options.globalName;
|
|
49
|
+
}
|
|
38
50
|
get name() {
|
|
39
51
|
return this.options.username;
|
|
40
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
|
+
}
|
|
41
59
|
get avatarHash() {
|
|
42
60
|
return this.options.avatar;
|
|
43
61
|
}
|
|
@@ -99,7 +117,7 @@ module.exports = class {
|
|
|
99
117
|
return this.options.banner;
|
|
100
118
|
}
|
|
101
119
|
get bannerColor() {
|
|
102
|
-
return this.options.
|
|
120
|
+
return this.options.bannerColor;
|
|
103
121
|
}
|
|
104
122
|
get banner() {
|
|
105
123
|
var banneru = this.bannerHash;
|
|
@@ -113,7 +131,7 @@ module.exports = class {
|
|
|
113
131
|
return banneru;
|
|
114
132
|
}
|
|
115
133
|
get accentColor() {
|
|
116
|
-
return this.options.
|
|
134
|
+
return this.options.accentColor;
|
|
117
135
|
}
|
|
118
136
|
get lang() {
|
|
119
137
|
return this.options.locale;
|
|
@@ -122,19 +140,19 @@ module.exports = class {
|
|
|
122
140
|
return (this.lang == "ru");
|
|
123
141
|
}
|
|
124
142
|
get is2FAEnabled() {
|
|
125
|
-
return this.options.
|
|
143
|
+
return this.options.mfaEnabled;
|
|
126
144
|
}
|
|
127
145
|
get hasNitro() {
|
|
128
|
-
return (this.isBot || this.options.
|
|
146
|
+
return (this.isBot || this.options.premiumType > 0);
|
|
129
147
|
}
|
|
130
148
|
get hasNitroClassic() {
|
|
131
|
-
return (this.options.
|
|
149
|
+
return (this.options.premiumType == 1);
|
|
132
150
|
}
|
|
133
151
|
get hasNitroBoost() {
|
|
134
|
-
return (this.isBot || this.options.
|
|
152
|
+
return (this.isBot || this.options.premiumType == 2);
|
|
135
153
|
}
|
|
136
154
|
get hasNitroBasic() {
|
|
137
|
-
return (this.options.
|
|
155
|
+
return (this.options.premiumType == 3);
|
|
138
156
|
}
|
|
139
157
|
get email() {
|
|
140
158
|
return this.options.email;
|
|
@@ -151,4 +169,14 @@ module.exports = class {
|
|
|
151
169
|
get isSystem() {
|
|
152
170
|
return this.options.system;
|
|
153
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
|
+
}
|
|
154
182
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catto.js",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Universal module for everything.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"body-parser": "^1.20.2",
|
|
43
|
-
"discord.js": "^14.
|
|
43
|
+
"discord.js": "^14.14.1",
|
|
44
44
|
"ejs": "^3.1.9",
|
|
45
45
|
"express": "^4.18.2",
|
|
46
|
-
"express-session": "^1.
|
|
46
|
+
"express-session": "^1.18.0",
|
|
47
47
|
"express-ws": "^5.0.2",
|
|
48
48
|
"request": "^2.88.2",
|
|
49
49
|
"session-file-store": "^1.5.0",
|
package/request.js
CHANGED
|
@@ -36,6 +36,15 @@ function post(options) {
|
|
|
36
36
|
return wrap("post", options);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* PATCH request.
|
|
41
|
+
* @param {object} options
|
|
42
|
+
* @return {promise}
|
|
43
|
+
*/
|
|
44
|
+
function patch(options) {
|
|
45
|
+
return wrap("patch", options);
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
/**
|
|
40
49
|
* PUT request.
|
|
41
50
|
* @param {object} options
|
|
@@ -46,5 +55,5 @@ function put(options) {
|
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
module.exports = {
|
|
49
|
-
get, post, put
|
|
50
|
-
};
|
|
58
|
+
get, post, patch, put
|
|
59
|
+
};
|