@imaentity/selfjs 1.6.9 → 1.9.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 +11 -4
- package/package.json +1 -1
- package/self.js +67 -4
package/docs.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
# Properties
|
|
3
2
|
- **status**: The enum that holds the different status types.
|
|
4
3
|
|
|
@@ -10,14 +9,18 @@
|
|
|
10
9
|
# Class
|
|
11
10
|
- **Client**: This class allows the interaction with the Discord server. The following are its methods:
|
|
12
11
|
|
|
12
|
+
- **userID**: The client's user ID.
|
|
13
|
+
|
|
14
|
+
- **token**: The client's token.
|
|
15
|
+
|
|
16
|
+
- **latency**: The latency of the client's websocket connection.
|
|
17
|
+
|
|
13
18
|
- **login(token, isMobile = false, logMsgs = false)**: Logs in the client to Discord.
|
|
14
19
|
|
|
15
20
|
- **onMessage(msgFunc)**: Function to be executed when a message is received.
|
|
16
21
|
|
|
17
22
|
- **onMessageEdit(editFunc)**: Function to be executed when a message is edited.
|
|
18
23
|
|
|
19
|
-
- **onMessageDelete(deleteFunc)**: Function to be executed when a message is deleted.
|
|
20
|
-
|
|
21
24
|
- **onStatusUpdate(statusFunc)**: Function to be executed when a status update occurs.
|
|
22
25
|
|
|
23
26
|
- **getDMChannel(userID)**: Gets the Direct Message (DM) channel for the specified user.
|
|
@@ -36,6 +39,10 @@
|
|
|
36
39
|
|
|
37
40
|
- **replyToMessage(channelID, messageID, message)**: Replies to a specified message.
|
|
38
41
|
|
|
42
|
+
- **createChannel(guildID, name, type, parentID = null)**: Creates a channel in a server based on the specified options.
|
|
43
|
+
|
|
44
|
+
- **setChannelPermissions(channelID, userID, allow, deny)**: Sets a users permissions in a channel based on the specified options.
|
|
45
|
+
|
|
39
46
|
- **getMessages(channelID, limit)**: Gets messages from a channel with a limit.
|
|
40
47
|
|
|
41
48
|
- **getUsers(guildID)**: Gets users from a guild.
|
|
@@ -68,7 +75,7 @@
|
|
|
68
75
|
|
|
69
76
|
- **setStatus(status, activities, afk = false)**: Sets the status of the client.
|
|
70
77
|
|
|
71
|
-
- **
|
|
78
|
+
- **createGroupChat(userIDs)**: Creates a new channel with the specified users.
|
|
72
79
|
|
|
73
80
|
- **startTyping(channelID)**: Simulates the client typing in a channel.
|
|
74
81
|
|
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.9.9
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const https = require("https");
|
|
@@ -86,6 +86,8 @@ module.exports = {
|
|
|
86
86
|
this.resumeURL = null;
|
|
87
87
|
this.statusUpdateFunction = null;
|
|
88
88
|
this.messageDeleteFunction = null;
|
|
89
|
+
this.latency = null;
|
|
90
|
+
this.beforeHB = null;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
login(token, isMobile = false, logMsgs = false) {
|
|
@@ -104,8 +106,8 @@ module.exports = {
|
|
|
104
106
|
token: this.token,
|
|
105
107
|
properties: {
|
|
106
108
|
$os: isMobile ? "linux" : "windows",
|
|
107
|
-
$browser: isMobile ? "Discord iOS" : "
|
|
108
|
-
$device: isMobile ? "discord.gblk" : "
|
|
109
|
+
$browser: isMobile ? "Discord iOS" : "SelfJS",
|
|
110
|
+
$device: isMobile ? "discord.gblk" : "SelfJS"
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
}));
|
|
@@ -118,14 +120,17 @@ module.exports = {
|
|
|
118
120
|
if(logMsgs) console.log("[MainControlSocket] Hello ACK received");
|
|
119
121
|
|
|
120
122
|
if(logMsgs) console.log("[MainControlSocket] Sending heartbeat");
|
|
123
|
+
this.beforeHB = Date.now();
|
|
121
124
|
this.socket.send(JSON.stringify({op: 1, d: this.sequenceID}));
|
|
122
125
|
|
|
123
126
|
setInterval(function() {
|
|
124
127
|
if(logMsgs) console.log("[MainControlSocket] Sending heartbeat");
|
|
128
|
+
this.beforeHB = Date.now();
|
|
125
129
|
this.socket.send(JSON.stringify({op: 1, d: this.sequenceID}));
|
|
126
130
|
}.bind(this), payload.d.heartbeat_interval);
|
|
127
131
|
} else if(payload.op == 11) {
|
|
128
132
|
if(logMsgs) console.log("[MainControlSocket] Heartbeat ACK received");
|
|
133
|
+
this.latency = Date.now() - this.beforeHB;
|
|
129
134
|
} else if(payload.op == 0) {
|
|
130
135
|
this.sequenceID = payload.s;
|
|
131
136
|
|
|
@@ -559,6 +564,64 @@ module.exports = {
|
|
|
559
564
|
});
|
|
560
565
|
}
|
|
561
566
|
|
|
567
|
+
createChannel(guildID, name, type, parentID = null) {
|
|
568
|
+
const channelData = JSON.stringify({name, type, parent_id: parentID});
|
|
569
|
+
const options = {
|
|
570
|
+
...module.exports.APIBaseOpt,
|
|
571
|
+
method: "POST",
|
|
572
|
+
path: `/api/v10/guilds/${guildID}/channels`,
|
|
573
|
+
headers: {
|
|
574
|
+
"Authorization": this.token,
|
|
575
|
+
"Content-Type": "application/json",
|
|
576
|
+
"Content-Length": channelData.length
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
return new Promise(function(resolve) {
|
|
581
|
+
const req = https.request(options, function(res) {
|
|
582
|
+
const chunks = [];
|
|
583
|
+
|
|
584
|
+
res.on("data", function(chunk) {
|
|
585
|
+
chunks.push(chunk);
|
|
586
|
+
}).on("end", function() {
|
|
587
|
+
resolve(JSON.parse(Buffer.concat(chunks)));
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
req.write(channelData);
|
|
592
|
+
req.end();
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
setChannelPermissions(channelID, userID, allow, deny) {
|
|
597
|
+
const permissionData = JSON.stringify({id: userID, allow, deny, type: 1});
|
|
598
|
+
const options = {
|
|
599
|
+
...module.exports.APIBaseOpt,
|
|
600
|
+
method: "PUT",
|
|
601
|
+
path: `/api/v10/channels/${channelID}/permissions/${userID}`,
|
|
602
|
+
headers: {
|
|
603
|
+
"Authorization": this.token,
|
|
604
|
+
"Content-Type": "application/json",
|
|
605
|
+
"Content-Length": permissionData.length
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
return new Promise(function(resolve) {
|
|
610
|
+
const req = https.request(options, function(res) {
|
|
611
|
+
const chunks = [];
|
|
612
|
+
|
|
613
|
+
res.on("data", function(chunk) {
|
|
614
|
+
chunks.push(chunk);
|
|
615
|
+
}).on("end", function() {
|
|
616
|
+
resolve(JSON.parse(Buffer.concat(chunks)));
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
req.write(permissionData);
|
|
621
|
+
req.end();
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
|
|
562
625
|
getMessages(channelID, limit) {
|
|
563
626
|
const options = {
|
|
564
627
|
...module.exports.APIBaseOpt,
|
|
@@ -895,7 +958,7 @@ module.exports = {
|
|
|
895
958
|
}.bind(this));
|
|
896
959
|
}
|
|
897
960
|
|
|
898
|
-
|
|
961
|
+
createGroupChat(userIDs) {
|
|
899
962
|
const userData = JSON.stringify({recipients: userIDs});
|
|
900
963
|
const options = {
|
|
901
964
|
...module.exports.APIBaseOpt,
|