@imaentity/selfjs 1.7.9 → 1.9.10
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 +5 -2
- package/package.json +1 -1
- package/self.js +65 -3
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
|
|
|
@@ -40,6 +39,10 @@
|
|
|
40
39
|
|
|
41
40
|
- **replyToMessage(channelID, messageID, message)**: Replies to a specified message.
|
|
42
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
|
+
|
|
43
46
|
- **getMessages(channelID, limit)**: Gets messages from a channel with a limit.
|
|
44
47
|
|
|
45
48
|
- **getUsers(guildID)**: Gets users from a guild.
|
|
@@ -72,7 +75,7 @@
|
|
|
72
75
|
|
|
73
76
|
- **setStatus(status, activities, afk = false)**: Sets the status of the client.
|
|
74
77
|
|
|
75
|
-
- **
|
|
78
|
+
- **createGroupChat(userIDs)**: Creates a new channel with the specified users.
|
|
76
79
|
|
|
77
80
|
- **startTyping(channelID)**: Simulates the client typing in a channel.
|
|
78
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.10
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const https = require("https");
|
|
@@ -88,6 +88,7 @@ module.exports = {
|
|
|
88
88
|
this.messageDeleteFunction = null;
|
|
89
89
|
this.latency = null;
|
|
90
90
|
this.beforeHB = null;
|
|
91
|
+
this.hearbeatInterval = null;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
login(token, isMobile = false, logMsgs = false) {
|
|
@@ -123,7 +124,7 @@ module.exports = {
|
|
|
123
124
|
this.beforeHB = Date.now();
|
|
124
125
|
this.socket.send(JSON.stringify({op: 1, d: this.sequenceID}));
|
|
125
126
|
|
|
126
|
-
setInterval(function() {
|
|
127
|
+
this.hearbeatInterval = setInterval(function() {
|
|
127
128
|
if(logMsgs) console.log("[MainControlSocket] Sending heartbeat");
|
|
128
129
|
this.beforeHB = Date.now();
|
|
129
130
|
this.socket.send(JSON.stringify({op: 1, d: this.sequenceID}));
|
|
@@ -176,6 +177,9 @@ module.exports = {
|
|
|
176
177
|
} else if(payload.op == 7) {
|
|
177
178
|
if(logMsgs) console.log("[MainControlSocket] Reconnect message received");
|
|
178
179
|
|
|
180
|
+
if(this.hearbeatInterval) clearInterval(this.hearbeatInterval);
|
|
181
|
+
this.socket.terminate();
|
|
182
|
+
|
|
179
183
|
this.socket = new ws("wss://gateway.discord.gg?v=10&encoding=json");
|
|
180
184
|
|
|
181
185
|
this.socket.on("open", function() {
|
|
@@ -564,6 +568,64 @@ module.exports = {
|
|
|
564
568
|
});
|
|
565
569
|
}
|
|
566
570
|
|
|
571
|
+
createChannel(guildID, name, type, parentID = null) {
|
|
572
|
+
const channelData = JSON.stringify({name, type, parent_id: parentID});
|
|
573
|
+
const options = {
|
|
574
|
+
...module.exports.APIBaseOpt,
|
|
575
|
+
method: "POST",
|
|
576
|
+
path: `/api/v10/guilds/${guildID}/channels`,
|
|
577
|
+
headers: {
|
|
578
|
+
"Authorization": this.token,
|
|
579
|
+
"Content-Type": "application/json",
|
|
580
|
+
"Content-Length": channelData.length
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
return new Promise(function(resolve) {
|
|
585
|
+
const req = https.request(options, function(res) {
|
|
586
|
+
const chunks = [];
|
|
587
|
+
|
|
588
|
+
res.on("data", function(chunk) {
|
|
589
|
+
chunks.push(chunk);
|
|
590
|
+
}).on("end", function() {
|
|
591
|
+
resolve(JSON.parse(Buffer.concat(chunks)));
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
req.write(channelData);
|
|
596
|
+
req.end();
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
setChannelPermissions(channelID, userID, allow, deny) {
|
|
601
|
+
const permissionData = JSON.stringify({id: userID, allow, deny, type: 1});
|
|
602
|
+
const options = {
|
|
603
|
+
...module.exports.APIBaseOpt,
|
|
604
|
+
method: "PUT",
|
|
605
|
+
path: `/api/v10/channels/${channelID}/permissions/${userID}`,
|
|
606
|
+
headers: {
|
|
607
|
+
"Authorization": this.token,
|
|
608
|
+
"Content-Type": "application/json",
|
|
609
|
+
"Content-Length": permissionData.length
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
return new Promise(function(resolve) {
|
|
614
|
+
const req = https.request(options, function(res) {
|
|
615
|
+
const chunks = [];
|
|
616
|
+
|
|
617
|
+
res.on("data", function(chunk) {
|
|
618
|
+
chunks.push(chunk);
|
|
619
|
+
}).on("end", function() {
|
|
620
|
+
resolve(JSON.parse(Buffer.concat(chunks)));
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
req.write(permissionData);
|
|
625
|
+
req.end();
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
|
|
567
629
|
getMessages(channelID, limit) {
|
|
568
630
|
const options = {
|
|
569
631
|
...module.exports.APIBaseOpt,
|
|
@@ -900,7 +962,7 @@ module.exports = {
|
|
|
900
962
|
}.bind(this));
|
|
901
963
|
}
|
|
902
964
|
|
|
903
|
-
|
|
965
|
+
createGroupChat(userIDs) {
|
|
904
966
|
const userData = JSON.stringify({recipients: userIDs});
|
|
905
967
|
const options = {
|
|
906
968
|
...module.exports.APIBaseOpt,
|