@imaentity/selfjs 1.5.9 → 1.7.9
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/docs.md +6 -0
- package/package.json +1 -1
- package/self.js +15 -3
package/docs.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
# Class
|
|
11
11
|
- **Client**: This class allows the interaction with the Discord server. The following are its methods:
|
|
12
12
|
|
|
13
|
+
- **userID**: The client's user ID.
|
|
14
|
+
|
|
15
|
+
- **token**: The client's token.
|
|
16
|
+
|
|
17
|
+
- **latency**: The latency of the client's websocket connection.
|
|
18
|
+
|
|
13
19
|
- **login(token, isMobile = false, logMsgs = false)**: Logs in the client to Discord.
|
|
14
20
|
|
|
15
21
|
- **onMessage(msgFunc)**: Function to be executed when a message is received.
|
package/package.json
CHANGED
package/self.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @name SelfJS
|
|
3
3
|
* @description Breaking Discord's TOS to bot user accounts.
|
|
4
4
|
* @author Эмберс
|
|
5
|
-
* @version 1.
|
|
5
|
+
* @version 1.7.9
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const https = require("https");
|
|
@@ -85,6 +85,9 @@ module.exports = {
|
|
|
85
85
|
this.sequenceID = null;
|
|
86
86
|
this.resumeURL = null;
|
|
87
87
|
this.statusUpdateFunction = null;
|
|
88
|
+
this.messageDeleteFunction = null;
|
|
89
|
+
this.latency = null;
|
|
90
|
+
this.beforeHB = null;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
login(token, isMobile = false, logMsgs = false) {
|
|
@@ -103,8 +106,8 @@ module.exports = {
|
|
|
103
106
|
token: this.token,
|
|
104
107
|
properties: {
|
|
105
108
|
$os: isMobile ? "linux" : "windows",
|
|
106
|
-
$browser: isMobile ? "Discord iOS" : "
|
|
107
|
-
$device: isMobile ? "discord.gblk" : "
|
|
109
|
+
$browser: isMobile ? "Discord iOS" : "SelfJS",
|
|
110
|
+
$device: isMobile ? "discord.gblk" : "SelfJS"
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
}));
|
|
@@ -117,14 +120,17 @@ module.exports = {
|
|
|
117
120
|
if(logMsgs) console.log("[MainControlSocket] Hello ACK received");
|
|
118
121
|
|
|
119
122
|
if(logMsgs) console.log("[MainControlSocket] Sending heartbeat");
|
|
123
|
+
this.beforeHB = Date.now();
|
|
120
124
|
this.socket.send(JSON.stringify({op: 1, d: this.sequenceID}));
|
|
121
125
|
|
|
122
126
|
setInterval(function() {
|
|
123
127
|
if(logMsgs) console.log("[MainControlSocket] Sending heartbeat");
|
|
128
|
+
this.beforeHB = Date.now();
|
|
124
129
|
this.socket.send(JSON.stringify({op: 1, d: this.sequenceID}));
|
|
125
130
|
}.bind(this), payload.d.heartbeat_interval);
|
|
126
131
|
} else if(payload.op == 11) {
|
|
127
132
|
if(logMsgs) console.log("[MainControlSocket] Heartbeat ACK received");
|
|
133
|
+
this.latency = Date.now() - this.beforeHB;
|
|
128
134
|
} else if(payload.op == 0) {
|
|
129
135
|
this.sequenceID = payload.s;
|
|
130
136
|
|
|
@@ -164,6 +170,8 @@ module.exports = {
|
|
|
164
170
|
try {payload.d.author.self = payload.d.author.id == this.userID;} catch(e) {}
|
|
165
171
|
|
|
166
172
|
if(typeof this.statusUpdateFunction == "function") this.statusUpdateFunction(payload.d);
|
|
173
|
+
} else if(payload.t == "MESSAGE_DELETE") {
|
|
174
|
+
if(typeof this.onDeleteFunction == "function") this.onDeleteFunction(payload.d);
|
|
167
175
|
}
|
|
168
176
|
} else if(payload.op == 7) {
|
|
169
177
|
if(logMsgs) console.log("[MainControlSocket] Reconnect message received");
|
|
@@ -199,6 +207,10 @@ module.exports = {
|
|
|
199
207
|
this.onEditFunction = editFunc;
|
|
200
208
|
}
|
|
201
209
|
|
|
210
|
+
onMessageDelete(deleteFunc) {
|
|
211
|
+
this.onDeleteFunction = deleteFunc;
|
|
212
|
+
}
|
|
213
|
+
|
|
202
214
|
onStatusUpdate(statusFunc) {
|
|
203
215
|
this.statusUpdateFunction = statusFunc;
|
|
204
216
|
}
|