discord-self-lite 0.1.15 → 0.1.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-self-lite",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "Lightweight Discord selfbot library",
5
5
  "keywords": [
6
6
  "discord",
@@ -29,7 +29,7 @@
29
29
  "node": ">=18.13.0"
30
30
  },
31
31
  "scripts": {
32
- "test": "eslint . && prettier --check .",
32
+ "lint": "eslint src tests eslint.config.js && prettier --check src tests eslint.config.js package.json package-lock.json .github/workflows",
33
33
  "format": "prettier --write .",
34
34
  "fix": "eslint . --fix && prettier --write .",
35
35
  "docs": "echo \"📚 Documentation available at docs/README.md\""
@@ -53,7 +53,7 @@
53
53
  "url": "https://github.com/sponsors/kyan0045"
54
54
  },
55
55
  "dependencies": {
56
- "ws": "^8.18.3"
56
+ "ws": "^8.21.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "eslint-config-prettier": "^10.1.8",
@@ -93,6 +93,15 @@ class Message {
93
93
  return this;
94
94
  }
95
95
 
96
+ /**
97
+ * Delete this message
98
+ * @returns {Promise<Message>} This message instance after deletion
99
+ */
100
+ async delete() {
101
+ await this.client.rest.deleteMessage(this.channelId, this.id);
102
+ return this;
103
+ }
104
+
96
105
  /**
97
106
  * Get the guild this message was sent in
98
107
  * @returns {Guild|null} The guild instance, or null if message was sent in DM
@@ -619,6 +619,18 @@ class RestManager {
619
619
  return updatedData;
620
620
  }
621
621
 
622
+ /**
623
+ * Delete a message from a channel
624
+ * @param {string} channelId - The channel ID
625
+ * @param {string} messageId - The message ID
626
+ * @returns {Promise<void>}
627
+ */
628
+ async deleteMessage(channelId, messageId) {
629
+ await this.request(`/channels/${channelId}/messages/${messageId}`, {
630
+ method: "DELETE",
631
+ });
632
+ }
633
+
622
634
  /**
623
635
  * React to a message
624
636
  * @param {string} channelId - The channel ID
@@ -5,10 +5,28 @@
5
5
  * @param {string|object} payload - Message content or payload object
6
6
  * @returns {Promise<object>} The sent message data
7
7
  */
8
+ const DISCORD_EPOCH = 1420070400000n;
9
+ let nonceIncrement = 0n;
10
+
11
+ function generateNonce() {
12
+ nonceIncrement = (nonceIncrement + 1n) & 0xfffn;
13
+ return (
14
+ ((BigInt(Date.now()) - DISCORD_EPOCH) << 22n) |
15
+ nonceIncrement
16
+ ).toString();
17
+ }
18
+
8
19
  async function sendMessage(rest, channelId, payload) {
9
- // If payload is a string, treat it as content
10
- const messagePayload =
20
+ const payloadOverrides =
11
21
  typeof payload === "string" ? { content: payload } : { ...payload };
22
+ const messagePayload = {
23
+ mobile_network_type: "unknown",
24
+ content: undefined,
25
+ nonce: generateNonce(),
26
+ tts: false,
27
+ flags: 0,
28
+ ...payloadOverrides,
29
+ };
12
30
 
13
31
  const filesToUpload = [];
14
32
  const keepAttachments = [];
@@ -349,6 +349,12 @@ class WebhookClient {
349
349
  if (options.threadId) {
350
350
  payload.thread_id = options.threadId;
351
351
  }
352
+ if (options.attachments !== undefined) {
353
+ payload.attachments = options.attachments;
354
+ }
355
+ if (options.files !== undefined) {
356
+ payload.files = options.files;
357
+ }
352
358
 
353
359
  return payload;
354
360
  }