@imaentity/selfjs 1.7.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.
Files changed (3) hide show
  1. package/docs.md +5 -2
  2. package/package.json +1 -1
  3. package/self.js +60 -2
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
- - **createChannel(userIDs)**: Creates a new channel with the specified users.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imaentity/selfjs",
3
- "version": "1.7.9",
3
+ "version": "1.9.9",
4
4
  "description": "Breaking Discord's TOS to bot user accounts.",
5
5
  "main": "self.js",
6
6
  "repository": {
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.7.9
5
+ * @version 1.9.9
6
6
  */
7
7
 
8
8
  const https = require("https");
@@ -564,6 +564,64 @@ module.exports = {
564
564
  });
565
565
  }
566
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
+
567
625
  getMessages(channelID, limit) {
568
626
  const options = {
569
627
  ...module.exports.APIBaseOpt,
@@ -900,7 +958,7 @@ module.exports = {
900
958
  }.bind(this));
901
959
  }
902
960
 
903
- createChannel(userIDs) {
961
+ createGroupChat(userIDs) {
904
962
  const userData = JSON.stringify({recipients: userIDs});
905
963
  const options = {
906
964
  ...module.exports.APIBaseOpt,