@imaentity/selfjs 2.9.11 → 3.1.0

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 (5) hide show
  1. package/README.md +6 -2
  2. package/changelog.log +25 -1
  3. package/docs.md +470 -91
  4. package/package.json +1 -1
  5. package/self.js +230 -585
package/README.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # SelfJS
2
- Install: `npm i @imaentity/selfjs`
2
+ Install Command: `npm i @imaentity/selfjs`
3
3
 
4
- An example of an echo bot:
4
+ ## Documentation
5
+ View Documentation [**Here**](https://github.com/ImaEntity/SelfJS/blob/master/docs.md)
6
+
7
+ ## Bot Example's
8
+ Echo Bot:
5
9
  ```JS
6
10
  const discord = require("@imaentity/SelfJS");
7
11
  const client = new discord.Client();
package/changelog.log CHANGED
@@ -1,5 +1,29 @@
1
1
  V2.9.11
2
2
  Added:
3
3
  changelog.log
4
+
4
5
  Changed:
5
- Client.setStatus now has default params
6
+ Client.setStatus now has default params
7
+
8
+ V2.10.11
9
+ Added:
10
+ Docs link to README.md
11
+
12
+ Changed:
13
+ Structure of docs.md
14
+
15
+ Removed:
16
+ The default option in the status enum
17
+
18
+ V3.0.0
19
+ Changed:
20
+ Overhaul to the structure of self.js
21
+
22
+ V3.1.0
23
+ Added:
24
+ Webhooks can now send files
25
+ Client.getUserProfile to fetch user profiles
26
+ Client.createServer to create a server
27
+
28
+ Changed:
29
+ Client.getUser now gets the actual user instead of their profile
package/docs.md CHANGED
@@ -1,92 +1,471 @@
1
- # Properties
2
- - **status**: The enum that holds the different status types.
3
-
4
- # Functions
5
- - **sleep(millis)**: A promise-based sleep function that pauses execution for the given time in milliseconds.
6
-
7
- - **sendWebhookMessage(webhookID, webhookToken, inputData)**: A function to send a webhook message. The webhook token and ID are provided, along with any input data.
8
-
9
- - **jsonEncode(jsonObject)**: Encodes a JSON object for use with the discord API. (Self does this automatically.)
10
-
11
- # Class
12
- - **Client**: This class allows the interaction with the Discord server. The following are its methods:
13
-
14
- - **userID**: The client's user ID.
1
+ # 📜 Documentation
2
+ Welcome To SelfJS Documentation
3
+
4
+ > [!WARNING]
5
+ > Doc's might not be Up-to-Date or 100% Correct.
6
+
7
+ ## Properties
8
+ + ### ℹ Activites Status:
9
+ The enum that holds the different status types.
10
+
11
+ **Types:**
12
+ ```
13
+ Playing : 0
14
+ Streaming : 1
15
+ Listening : 2
16
+ Watching : 3
17
+ Custom : 4
18
+ Competing : 5
19
+ ```
20
+
21
+ + ### 🎮 Status:
22
+ The string that holds the different status types.
23
+
24
+ **Types:**
25
+ ```
26
+ "online",
27
+ "dnd",
28
+ "idle",
29
+ "invisible"
30
+ ```
31
+
32
+ ## Functions
33
+ + ### 😴 Sleep:
34
+ A promise-based sleep function that pauses execution for the given time in milliseconds.
35
+ > Paramaters: Miliseconds (Int)
15
36
 
16
- - **token**: The client's token.
17
-
18
- - **latency**: The latency of the client's websocket connection.
19
-
20
- - **login(token, isMobile = false, logMsgs = false)**: Logs in the client to Discord.
21
-
22
- - **onMessage(msgFunc)**: Function to be executed when a message is received.
23
-
24
- - **onMessageEdit(editFunc)**: Function to be executed when a message is edited.
25
-
26
- - **onStatusUpdate(statusFunc)**: Function to be executed when a status update occurs.
27
-
28
- - **getDMChannel(userID)**: Gets the Direct Message (DM) channel for the specified user.
29
-
30
- - **getRoles(serverID, userID)**: Gets the roles for a user in a server.
31
-
32
- - **uploadFile(channelID, fileName, isSpoiled = false, msgContent = "", messageID = null)**: Uploads a file to the specified channel.
33
-
34
- - **search(channelID, options)**: Search for messages in a channel based on the specified options.
35
-
36
- - **getUserData(userID)**: Gets the data of a user.
37
-
38
- - **setRolesForMember(serverID, userID, roleIDs)**: Sets roles for a member in a server.
39
-
40
- - **sendMessage(channelID, message)**: Sends a message to a specified channel.
41
-
42
- - **replyToMessage(channelID, messageID, message)**: Replies to a specified message.
43
-
44
- - **createChannel(guildID, name, type, parentID = null)**: Creates a channel in a server based on the specified options.
45
-
46
- - **setChannelPermissions(channelID, userID, allow, deny)**: Sets a users permissions in a channel based on the specified options.
47
-
48
- - **getMessages(channelID, limit)**: Gets messages from a channel with a limit.
49
-
50
- - **getUsers(guildID)**: Gets users from a guild.
51
-
52
- - **removeFromChannel(channelID, userID)**: Removes a user from a channel.
53
-
54
- - **leaveChannel(channelID)**: Leaves a channel.
55
-
56
- - **ring(channelID, userIDs)**: Starts a call with the specified users in a channel.
57
-
58
- - **stopRinging(channelID, userIDs)**: Stops ringing the specified users in a channel.
59
-
60
- - **addToChannel(channelID, userID)**: Adds a user to a channel.
61
-
62
- - **getAvatar(userID, size = 256)**: Gets the avatar of a user.
63
-
64
- - **addFriend(userID)**: Sends a friend request to a user.
65
-
66
- - **editMessage(channelID, messageID, newMessage)**: Edits a message.
67
-
68
- - **removeFriend(userID)**: Removes a user from the friend list.
69
-
70
- - **renameChannel(channelID, channelName)**: Renames a channel.
71
-
72
- - **block(userID)**: Blocks a user.
73
-
74
- - **unblock(userID)**: Unblocks a user.
75
-
76
- - **deleteMessage(channelID, messageID)**: Deletes a message.
77
-
78
- - **setStatus(status, activities, afk = false)**: Sets the status of the client.
79
-
80
- - **createGroupChat(userIDs)**: Creates a new channel with the specified users.
81
-
82
- - **startTyping(channelID)**: Simulates the client typing in a channel.
83
-
84
- - **pinMessage(channelID, messageID)**: Pins a message in a channel.
85
-
86
- - **unpinMessage(channelID, messageID)**: Unpins a message in a channel.
87
-
88
- - **editNote(userID, note)**: Edits a note for a user.
89
-
90
- - **getChannelData(channelID)**: Gets data of a channel.
91
-
92
- - **transferOwnership(channelID, userID)**: Transfers ownership of a channel to another user.
37
+ <br>Example:
38
+ ```javascript
39
+ self.sleep(1000);
40
+ ```
41
+ + ### 🤖 Send Webhook Message:
42
+ A function to send a webhook message. The webhook token and ID are provided, along with any input data.
43
+ >Paramaters: webhookID (String), webhookToken (String or JSON), inputData (JSON)
44
+
45
+ <br>Example:
46
+ ```javascript
47
+ self.sendWebhookMessage("012345678910111213", "012345678910111213141516.123456.123456789101112131415161718", {
48
+ "content": "Sending Content Through Webhook"
49
+ });
50
+ ```
51
+ or
52
+ ```javascript
53
+ self.sendWebhookMessage("https://discord.com/api/webhooks/01234567891011121314/012345678910111213141516.123456.123456789101112131415161718", {
54
+ "content": "Sending Content Through Webhook"
55
+ });
56
+ ```
57
+
58
+ + ### 📄 JSON Encode
59
+ Encodes a JSON object for use with the discord API. (Self does this automatically.)
60
+ >Paramaters: jsonObject (JSON)
61
+
62
+ <br>Example:
63
+ ```javascript
64
+ self.jsonEncode({content: "Hello, world!"});
65
+ ```
66
+
67
+ ## Class
68
+ + ### Client
69
+ This class allows the interaction with the Discord server.
70
+
71
+ <br>Example:
72
+ ```javascript
73
+ const self = require("@imaentity/selfjs");
74
+ const client = new self.Client();
75
+ ```
76
+
77
+ + ### 🧑 UserID: The client's user ID.
78
+
79
+ + ### 🎟 Token: The client's token.
80
+
81
+ + ### 📶 Latency: The latency of the client's websocket connection.
82
+
83
+ + ### 🔑 Login (REQUIRED)
84
+ Logs in the client to Discord.
85
+ >Paramaters: Token (String), isMobile (Boolean | false), logMsgs (Boolean | false)
86
+
87
+ <br>Example:
88
+ ```javascript
89
+ client.login("012345678910111213141516.123456.123456789101112131415161718");
90
+ ```
91
+
92
+ + ### 💬 onMessage
93
+ Function to be executed when a message is received.
94
+ >Paramaters: msgFunc (Function)
95
+
96
+ <br>Example:
97
+ ```javascript
98
+ client.onMessage(async function(msg) {
99
+ console.log("Message Received: " + msg.content);
100
+ });
101
+ ```
102
+
103
+ + ### onMessageEdit
104
+ Function to be executed when a message is edited.
105
+ >Paramaters: editFunc (Function)
106
+
107
+ <br>Example:
108
+ ```javascript
109
+ client.onMessageEdit(async function(msg) {
110
+ console.log("Message Edited: " + msg.content);
111
+ });
112
+ ```
113
+
114
+ + ### 🚮 onMessageDelete
115
+ Function to be executed when a message is deleted.
116
+ Deleted message objects only receive the channel and message ids.
117
+ >Paramaters: deleteFunc (Function)
118
+
119
+ <br>Example:
120
+ ```javascript
121
+ client.onMessageDelete(async function(msg) {
122
+ console.log("Message Deleted: " + msg.id);
123
+ });
124
+ ```
125
+
126
+ + ### 🕶 onStatusUpdate
127
+ Function to be executed when a status update occurs.
128
+ >Paramaters: statusFunc (Function)
129
+
130
+ <br>Example:
131
+ ```javascript
132
+ client.onStatusUpdate(async function(status) {
133
+ console.log(status);
134
+ });
135
+ ```
136
+
137
+ + ### 🔏 getDMChannel
138
+ Gets the Direct Message (DM) channel for the specified user.
139
+ >Paramaters: userID (String)
140
+
141
+ <br>Example:
142
+ ```javascript
143
+ client.getDMChannel("01234567891011121314");
144
+ ```
145
+
146
+ + ### 🧪 getRoles
147
+ Gets the roles for a user in a server.
148
+ >Paramaters: serverID (String), userID (String)
149
+
150
+ <br>Example:
151
+ ```javascript
152
+ client.getRoles("01234567891011121314", "41312111019876543210");
153
+ ```
154
+
155
+ + ### 📁 uploadFile
156
+ Uploads a file to the specified channel.
157
+ >Paramaters: channelID (String), fileName (String), isSpoiled (Boolean | false), msgContent (String | ""), messageID (String | null)
158
+
159
+ <br>Example:
160
+ ```javascript
161
+ client.uploadFile("01234567891011121314", "image.png", true, "Message Related to The Image", "41312111019876543210");
162
+ ```
163
+
164
+ + ### 🔍 search
165
+ Search for messages in a channel based on the specified options.
166
+ >Paramaters: channelID (String), options (JSON)
167
+
168
+ <br>Example:
169
+ ```javascript
170
+ client.search("01234567891011121314", {
171
+ content: "Hello, world!"
172
+ });
173
+ ```
174
+
175
+ + ### 👤 getUserProfile
176
+ Gets the profile of a user.
177
+ >Paramaters: userID (String)
178
+
179
+ <br>Example:
180
+ ```javascript
181
+ client.getUserProfile("01234567891011121314");
182
+ ```
183
+
184
+ + ### 👤 getUserData
185
+ Gets the data of a user.
186
+ >Paramaters: userID (String)
187
+
188
+ <br>Example:
189
+ ```javascript
190
+ client.getUserData("01234567891011121314");
191
+ ```
192
+
193
+ + ### 🔨 setRolesForMember
194
+ Sets roles for a member in a server.
195
+ >Paramaters: serverID (String), userID (String), roleIDs (Array)
196
+
197
+ <br>Example:
198
+ ```javascript
199
+ client.setRolesForMember("01234567891011121314", "41312111019876543210", [
200
+ "1285712985712985712",
201
+ "1284578912561872568",
202
+ "9127498127459812749"
203
+ ]);
204
+ ```
205
+
206
+ + ### 🗣 sendMessage
207
+ Sends a message to a specified channel.
208
+ >Paramaters: channelID (String), message (String)
209
+
210
+ <br>Example:
211
+ ```javascript
212
+ client.sendMessage("01234567891011121314", "Message");
213
+ ```
214
+
215
+ + ### 👨🏻‍🤝‍👨🏻 replyToMessage
216
+ Replies to a specified message.
217
+ >Paramaters: channelID (String), messageID (String), message (String)
218
+
219
+ <br>Example:
220
+ ```javascript
221
+ client.replyToMessage("01234567891011121314", "41312111019876543210", "Replied Message");
222
+ ```
223
+
224
+ + ### 📔 createChannel
225
+ Creates a channel in a server based on the specified options.
226
+ >Paramaters: guildID (String), name (String), type (Int), parentID (String | null)
227
+
228
+ <br>Example:
229
+ ```javascript
230
+ // 0 = GUILD_TEXT
231
+
232
+ client.createChannel("01234567891011121314", "new-channel", 0, "41312111019876543210");
233
+ ```
234
+
235
+ + ### 👑 setChannelPermissons
236
+ Sets a users permissions in a channel based on the specified options.
237
+ >Paramaters: channelID (String), userID (String), allow (String | 0), deny (String | 0)
238
+
239
+ <br>Example:
240
+ ```javascript
241
+ client.setChannelPermissons("01234567891011121314", "41312111019876543210");
242
+ ```
243
+
244
+ + ### 📖 getMessages
245
+ Gets messages from a channel with a limit.
246
+ >Paramaters: channelID (String), limit (Int)
247
+
248
+ <br>Example:
249
+ ```javascript
250
+ client.getMessages("01234567891011121314", 10);
251
+ ```
252
+
253
+ + ### 🏙 getUsers
254
+ Gets users from a guild.
255
+ >Paramaters: guildID (String)
256
+
257
+ <br>Example:
258
+ ```javascript
259
+ client.getUsers("01234567891011121314");
260
+ ```
261
+
262
+ + ### ❌ removeFromChannel
263
+ Removes a user from a channel.
264
+ >Paramaters: channelID (String), userID (String)
265
+
266
+ <br>Example:
267
+ ```javascript
268
+ client.removeFromChannel("01234567891011121314", "41312111019876543210");
269
+ ```
270
+
271
+ + ### 🏃‍♀️ leaveChannel
272
+ Leaves a channel.
273
+ >Paramaters: channelID (String)
274
+
275
+ <br>Example:
276
+ ```javascript
277
+ client.leaveChannel("01234567891011121314");
278
+ ```
279
+
280
+ + ### 📞 ring
281
+ Starts a call with the specified users in a channel.
282
+ >Paramaters: channelID (String), userIDs (Array)
283
+
284
+ <br>Example:
285
+ ```javascript
286
+ client.ring("01234567891011121314", [
287
+ "12549812509818205",
288
+ "19024578912857987"
289
+ ]);
290
+ ```
291
+
292
+ + ### 📴 stopRinging
293
+ Stops ringing the specified users in a channel.
294
+ >Paramaters: channelID (String), userIDs (Array)
295
+
296
+ <br>Example:
297
+ ```javascript
298
+ client.stopRinging("01234567891011121314", [
299
+ "12549812509818205",
300
+ "19024578912857987"
301
+ ]);
302
+ ```
303
+
304
+ + ### ➕ addToChannel
305
+ Adds a user to a channel.
306
+ >Paramaters: channelID (String), userID (String)
307
+
308
+ <br>Example:
309
+ ```javascript
310
+ client.addToChannel("01234567891011121314", "41312111019876543210");
311
+ ```
312
+
313
+ + ### 📷 getAvatar
314
+ Gets the avatar of a user.
315
+ >Paramaters: userID (String), size (Int | 256)
316
+
317
+ <br>Example:
318
+ ```javascript
319
+ client.getAvatar("01234567891011121314");
320
+ ```
321
+
322
+ + ### 🤼 addFriend
323
+ Sends a friend request to a user.
324
+ >Paramaters: userID (String)
325
+
326
+ <br>Example:
327
+ ```javascript
328
+ client.addFriend("01234567891011121314");
329
+ ```
330
+
331
+ + ### ➕ createServer
332
+ Creates a server with the given options.
333
+ >Paramaters: options ({name: String, icon: String | null})
334
+
335
+ <br>Example:
336
+ ```javascript
337
+ client.createServer({name: "My Server", icon: "data:image/png;base64,aGloaSA6Mw=="});
338
+ ```
339
+
340
+ + ### 🖊 editMessage
341
+ Edits a message.
342
+ >Paramaters: channelID (String), messageID (String), message (String)
343
+
344
+ <br>Example:
345
+ ```javascript
346
+ client.editMessage("01234567891011121314", "41312111019876543210", "Edited Message");
347
+ ```
348
+
349
+ + ### 👋 removeFriend
350
+ Removes a user from the friend list.
351
+ >Paramaters: userID (String)
352
+
353
+ <br>Example:
354
+ ```javascript
355
+ client.removeFriend("01234567891011121314");
356
+ ```
357
+
358
+ + ### 📛 renameChannel
359
+ Renames a channel.
360
+ >Paramaters: channelID (String), channelName (String)
361
+
362
+ <br>Example:
363
+ ```javascript
364
+ client.renameChannel("01234567891011121314", "Renamed Channel");
365
+ ```
366
+
367
+ + ### ❎ block
368
+ Blocks a user.
369
+ >Paramaters: userID (String)
370
+
371
+ <br>Example:
372
+ ```javascript
373
+ client.block("01234567891011121314");
374
+ ```
375
+
376
+ + ### ✅ unblock
377
+ Unblocks a user.
378
+ >Paramaters: userID (String)
379
+
380
+ <br>Example:
381
+ ```javascript
382
+ client.unblock("01234567891011121314");
383
+ ```
384
+
385
+ + ### 🚮 deleteMessage
386
+ Deletes a message.
387
+ >Paramaters: channelID (String), messageID (String)
388
+
389
+ <br>Example:
390
+ ```javascript
391
+ client.deleteMessage("01234567891011121314", "41312111019876543210");
392
+ ```
393
+
394
+ + ### 🗿 setStatus
395
+ Sets the status of the client.
396
+ >Paramaters: status (String), activites (Array), afk (Boolean | false)
397
+
398
+ <br>Example:
399
+ ```javascript
400
+ client.setStatus("dnd", [{
401
+ name: "with the discord API",
402
+ type: self.status.PLAYING
403
+ }]);
404
+ ```
405
+
406
+ + ### 🤼 createGroupChat
407
+ Creates a new channel with the specified users.
408
+ >Paramaters: userIDs (Array)
409
+
410
+ <br>Example:
411
+ ```javascript
412
+ client.createGroupChat([
413
+ "12847128957125",
414
+ "12905901285798",
415
+ "64837698943868"
416
+ ]);
417
+ ```
418
+
419
+ + ### 🎹 startTyping
420
+ Simulates the client typing in a channel.
421
+ >Paramaters: channelID (String)
422
+
423
+ <br>Example:
424
+ ```javascript
425
+ client.startTyping("01234567891011121314");
426
+ ```
427
+
428
+ + ### 📌 pinMessage
429
+ Pins a message in a channel.
430
+ >Paramaters: channelID (String), messageID (String)
431
+
432
+ <br>Example:
433
+ ```javascript
434
+ client.pinMessage("01234567891011121314", "41312111019876543210");
435
+ ```
436
+
437
+ + ### ❌ unpinMessage
438
+ Unpins a message in a channel.
439
+ >Paramaters: channelID (String), messageID (String)
440
+
441
+ <br>Example:
442
+ ```javascript
443
+ client.unpinMessage("01234567891011121314", "41312111019876543210");
444
+ ```
445
+
446
+ + ### 📝 editNote
447
+ Edits a note for a user.
448
+ >Paramaters: userID (String), note (String)
449
+
450
+ <br>Example:
451
+ ```javascript
452
+ client.editNote("01234567891011121314", "Edited Note");
453
+ ```
454
+
455
+ + ### 💾 getChannelData
456
+ Gets data of a channel.
457
+ >Paramaters: channelID (String)
458
+
459
+ <br>Example:
460
+ ```javascript
461
+ client.getChannelData("01234567891011121314");
462
+ ```
463
+
464
+ + ### 👑 transferOwnership
465
+ Transfers ownership of a channel to another user.
466
+ >Paramaters: channelID (String), userID (String)
467
+
468
+ <br>Example:
469
+ ```javascript
470
+ client.transferOwnership("01234567891011121314", "41312111019876543210");
471
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imaentity/selfjs",
3
- "version": "2.9.11",
3
+ "version": "3.1.0",
4
4
  "description": "Breaking Discord's TOS to bot user accounts.",
5
5
  "main": "self.js",
6
6
  "repository": {