@imaentity/selfjs 2.9.11 → 3.0.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 +16 -1
  3. package/docs.md +452 -91
  4. package/package.json +1 -1
  5. package/self.js +149 -561
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,20 @@
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
+ Major overhaul to the structure of self.js
package/docs.md CHANGED
@@ -1,92 +1,453 @@
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
+ + ### 👤 getUserData
176
+ Gets the data of a user.
177
+ >Paramaters: userID (String)
178
+
179
+ <br>Example:
180
+ ```javascript
181
+ client.getUserData("01234567891011121314");
182
+ ```
183
+
184
+ + ### 🔨 setRolesForMember
185
+ Sets roles for a member in a server.
186
+ >Paramaters: serverID (String), userID (String), roleIDs (Array)
187
+
188
+ <br>Example:
189
+ ```javascript
190
+ client.setRolesForMember("01234567891011121314", "41312111019876543210", [
191
+ "1285712985712985712",
192
+ "1284578912561872568",
193
+ "9127498127459812749"
194
+ ]);
195
+ ```
196
+
197
+ + ### 🗣 sendMessage
198
+ Sends a message to a specified channel.
199
+ >Paramaters: channelID (String), message (String)
200
+
201
+ <br>Example:
202
+ ```javascript
203
+ client.sendMessage("01234567891011121314", "Message");
204
+ ```
205
+
206
+ + ### 👨🏻‍🤝‍👨🏻 replyToMessage
207
+ Replies to a specified message.
208
+ >Paramaters: channelID (String), messageID (String), message (String)
209
+
210
+ <br>Example:
211
+ ```javascript
212
+ client.replyToMessage("01234567891011121314", "41312111019876543210", "Replied Message");
213
+ ```
214
+
215
+ + ### 📔 createChannel
216
+ Creates a channel in a server based on the specified options.
217
+ >Paramaters: guildID (String), name (String), type (Int), parentID (String | null)
218
+
219
+ <br>Example:
220
+ ```javascript
221
+ // 0 = GUILD_TEXT
222
+
223
+ client.createChannel("01234567891011121314", "new-channel", 0, "41312111019876543210");
224
+ ```
225
+
226
+ + ### 👑 setChannelPermissons
227
+ Sets a users permissions in a channel based on the specified options.
228
+ >Paramaters: channelID (String), userID (String), allow (String | 0), deny (String | 0)
229
+
230
+ <br>Example:
231
+ ```javascript
232
+ client.setChannelPermissons("01234567891011121314", "41312111019876543210");
233
+ ```
234
+
235
+ + ### 📖 getMessages
236
+ Gets messages from a channel with a limit.
237
+ >Paramaters: channelID (String), limit (Int)
238
+
239
+ <br>Example:
240
+ ```javascript
241
+ client.getMessages("01234567891011121314", 10);
242
+ ```
243
+
244
+ + ### 🏙 getUsers
245
+ Gets users from a guild.
246
+ >Paramaters: guildID (String)
247
+
248
+ <br>Example:
249
+ ```javascript
250
+ client.getUsers("01234567891011121314");
251
+ ```
252
+
253
+ + ### ❌ removeFromChannel
254
+ Removes a user from a channel.
255
+ >Paramaters: channelID (String), userID (String)
256
+
257
+ <br>Example:
258
+ ```javascript
259
+ client.removeFromChannel("01234567891011121314", "41312111019876543210");
260
+ ```
261
+
262
+ + ### 🏃‍♀️ leaveChannel
263
+ Leaves a channel.
264
+ >Paramaters: channelID (String)
265
+
266
+ <br>Example:
267
+ ```javascript
268
+ client.leaveChannel("01234567891011121314");
269
+ ```
270
+
271
+ + ### 📞 ring
272
+ Starts a call with the specified users in a channel.
273
+ >Paramaters: channelID (String), userIDs (Array)
274
+
275
+ <br>Example:
276
+ ```javascript
277
+ client.ring("01234567891011121314", [
278
+ "12549812509818205",
279
+ "19024578912857987"
280
+ ]);
281
+ ```
282
+
283
+ + ### 📴 stopRinging
284
+ Stops ringing the specified users in a channel.
285
+ >Paramaters: channelID (String), userIDs (Array)
286
+
287
+ <br>Example:
288
+ ```javascript
289
+ client.stopRinging("01234567891011121314", [
290
+ "12549812509818205",
291
+ "19024578912857987"
292
+ ]);
293
+ ```
294
+
295
+ + ### ➕ addToChannel
296
+ Adds a user to a channel.
297
+ >Paramaters: channelID (String), userID (String)
298
+
299
+ <br>Example:
300
+ ```javascript
301
+ client.addToChannel("01234567891011121314", "41312111019876543210");
302
+ ```
303
+
304
+ + ### 📷 getAvatar
305
+ Gets the avatar of a user.
306
+ >Paramaters: userID (String), size (Int | 256)
307
+
308
+ <br>Example:
309
+ ```javascript
310
+ client.getAvatar("01234567891011121314");
311
+ ```
312
+
313
+ + ### 🤼 addFriend
314
+ Sends a friend request to a user.
315
+ >Paramaters: userID (String)
316
+
317
+ <br>Example:
318
+ ```javascript
319
+ client.addFriend("01234567891011121314");
320
+ ```
321
+
322
+ + ### 🖊 editMessage
323
+ Edits a message.
324
+ >Paramaters: channelID (String), messageID (String), message (String)
325
+
326
+ <br>Example:
327
+ ```javascript
328
+ client.editMessage("01234567891011121314", "41312111019876543210", "Edited Message");
329
+ ```
330
+
331
+ + ### 👋 removeFriend
332
+ Removes a user from the friend list.
333
+ >Paramaters: userID (String)
334
+
335
+ <br>Example:
336
+ ```javascript
337
+ client.removeFriend("01234567891011121314");
338
+ ```
339
+
340
+ + ### 📛 renameChannel
341
+ Renames a channel.
342
+ >Paramaters: channelID (String), channelName (String)
343
+
344
+ <br>Example:
345
+ ```javascript
346
+ client.renameChannel("01234567891011121314", "Renamed Channel");
347
+ ```
348
+
349
+ + ### ❎ block
350
+ Blocks a user.
351
+ >Paramaters: userID (String)
352
+
353
+ <br>Example:
354
+ ```javascript
355
+ client.block("01234567891011121314");
356
+ ```
357
+
358
+ + ### ✅ unblock
359
+ Unblocks a user.
360
+ >Paramaters: userID (String)
361
+
362
+ <br>Example:
363
+ ```javascript
364
+ client.unblock("01234567891011121314");
365
+ ```
366
+
367
+ + ### 🚮 deleteMessage
368
+ Deletes a message.
369
+ >Paramaters: channelID (String), messageID (String)
370
+
371
+ <br>Example:
372
+ ```javascript
373
+ client.deleteMessage("01234567891011121314", "41312111019876543210");
374
+ ```
375
+
376
+ + ### 🗿 setStatus
377
+ Sets the status of the client.
378
+ >Paramaters: status (String), activites (Array), afk (Boolean | false)
379
+
380
+ <br>Example:
381
+ ```javascript
382
+ client.setStatus("dnd", [{
383
+ name: "with the discord API",
384
+ type: self.status.PLAYING
385
+ }]);
386
+ ```
387
+
388
+ + ### 🤼 createGroupChat
389
+ Creates a new channel with the specified users.
390
+ >Paramaters: userIDs (Array)
391
+
392
+ <br>Example:
393
+ ```javascript
394
+ client.createGroupChat([
395
+ "12847128957125",
396
+ "12905901285798",
397
+ "64837698943868"
398
+ ]);
399
+ ```
400
+
401
+ + ### 🎹 startTyping
402
+ Simulates the client typing in a channel.
403
+ >Paramaters: channelID (String)
404
+
405
+ <br>Example:
406
+ ```javascript
407
+ client.startTyping("01234567891011121314");
408
+ ```
409
+
410
+ + ### 📌 pinMessage
411
+ Pins a message in a channel.
412
+ >Paramaters: channelID (String), messageID (String)
413
+
414
+ <br>Example:
415
+ ```javascript
416
+ client.pinMessage("01234567891011121314", "41312111019876543210");
417
+ ```
418
+
419
+ + ### ❌ unpinMessage
420
+ Unpins a message in a channel.
421
+ >Paramaters: channelID (String), messageID (String)
422
+
423
+ <br>Example:
424
+ ```javascript
425
+ client.unpinMessage("01234567891011121314", "41312111019876543210");
426
+ ```
427
+
428
+ + ### 📝 editNote
429
+ Edits a note for a user.
430
+ >Paramaters: userID (String), note (String)
431
+
432
+ <br>Example:
433
+ ```javascript
434
+ client.editNote("01234567891011121314", "Edited Note");
435
+ ```
436
+
437
+ + ### 💾 getChannelData
438
+ Gets data of a channel.
439
+ >Paramaters: channelID (String)
440
+
441
+ <br>Example:
442
+ ```javascript
443
+ client.getChannelData("01234567891011121314");
444
+ ```
445
+
446
+ + ### 👑 transferOwnership
447
+ Transfers ownership of a channel to another user.
448
+ >Paramaters: channelID (String), userID (String)
449
+
450
+ <br>Example:
451
+ ```javascript
452
+ client.transferOwnership("01234567891011121314", "41312111019876543210");
453
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imaentity/selfjs",
3
- "version": "2.9.11",
3
+ "version": "3.0.0",
4
4
  "description": "Breaking Discord's TOS to bot user accounts.",
5
5
  "main": "self.js",
6
6
  "repository": {