discord-self-lite 0.1.14 → 0.1.16
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,63 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "discord-self-lite",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Lightweight Discord selfbot library",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"discord",
|
|
7
|
-
"selfbot",
|
|
8
|
-
"bot",
|
|
9
|
-
"api",
|
|
10
|
-
"websocket",
|
|
11
|
-
"discord-api",
|
|
12
|
-
"discord-bot",
|
|
13
|
-
"discord-selfbot",
|
|
14
|
-
"lightweight",
|
|
15
|
-
"nodejs"
|
|
16
|
-
],
|
|
17
|
-
"main": "src/index.js",
|
|
18
|
-
"files": [
|
|
19
|
-
"src",
|
|
20
|
-
"README.md",
|
|
21
|
-
"LICENSE"
|
|
22
|
-
],
|
|
23
|
-
"exports": {
|
|
24
|
-
".": "./src/index.js",
|
|
25
|
-
"./classes/Client": "./src/classes/Client.js",
|
|
26
|
-
"./classes/WebhookClient": "./src/connection/webhook/WebhookClient.js"
|
|
27
|
-
},
|
|
28
|
-
"engines": {
|
|
29
|
-
"node": ">=18.13.0"
|
|
30
|
-
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"test": "eslint . && prettier --check .",
|
|
33
|
-
"format": "prettier --write .",
|
|
34
|
-
"fix": "eslint . --fix && prettier --write .",
|
|
35
|
-
"docs": "echo \"📚 Documentation available at docs/README.md\""
|
|
36
|
-
},
|
|
37
|
-
"repository": {
|
|
38
|
-
"type": "git",
|
|
39
|
-
"url": "git+https://github.com/kyan0045/discord-self-lite.git"
|
|
40
|
-
},
|
|
41
|
-
"author": {
|
|
42
|
-
"name": "Kyan Bosman",
|
|
43
|
-
"email": "contact@kyanbosman.com",
|
|
44
|
-
"url": "https://github.com/kyan0045"
|
|
45
|
-
},
|
|
46
|
-
"license": "GPL-3.0-or-later",
|
|
47
|
-
"bugs": {
|
|
48
|
-
"url": "https://github.com/kyan0045/discord-self-lite/issues"
|
|
49
|
-
},
|
|
50
|
-
"homepage": "https://github.com/kyan0045/discord-self-lite#readme",
|
|
51
|
-
"funding": {
|
|
52
|
-
"type": "github",
|
|
53
|
-
"url": "https://github.com/sponsors/kyan0045"
|
|
54
|
-
},
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"ws": "^8.18.3"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"eslint-config-prettier": "^10.1.8",
|
|
60
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
61
|
-
"prettier": "^3.6.2"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "discord-self-lite",
|
|
3
|
+
"version": "0.1.16",
|
|
4
|
+
"description": "Lightweight Discord selfbot library",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"discord",
|
|
7
|
+
"selfbot",
|
|
8
|
+
"bot",
|
|
9
|
+
"api",
|
|
10
|
+
"websocket",
|
|
11
|
+
"discord-api",
|
|
12
|
+
"discord-bot",
|
|
13
|
+
"discord-selfbot",
|
|
14
|
+
"lightweight",
|
|
15
|
+
"nodejs"
|
|
16
|
+
],
|
|
17
|
+
"main": "src/index.js",
|
|
18
|
+
"files": [
|
|
19
|
+
"src",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": "./src/index.js",
|
|
25
|
+
"./classes/Client": "./src/classes/Client.js",
|
|
26
|
+
"./classes/WebhookClient": "./src/connection/webhook/WebhookClient.js"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18.13.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "eslint . && prettier --check .",
|
|
33
|
+
"format": "prettier --write .",
|
|
34
|
+
"fix": "eslint . --fix && prettier --write .",
|
|
35
|
+
"docs": "echo \"📚 Documentation available at docs/README.md\""
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/kyan0045/discord-self-lite.git"
|
|
40
|
+
},
|
|
41
|
+
"author": {
|
|
42
|
+
"name": "Kyan Bosman",
|
|
43
|
+
"email": "contact@kyanbosman.com",
|
|
44
|
+
"url": "https://github.com/kyan0045"
|
|
45
|
+
},
|
|
46
|
+
"license": "GPL-3.0-or-later",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/kyan0045/discord-self-lite/issues"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/kyan0045/discord-self-lite#readme",
|
|
51
|
+
"funding": {
|
|
52
|
+
"type": "github",
|
|
53
|
+
"url": "https://github.com/sponsors/kyan0045"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"ws": "^8.18.3"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"eslint-config-prettier": "^10.1.8",
|
|
60
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
61
|
+
"prettier": "^3.6.2"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/classes/Channel.js
CHANGED
|
@@ -74,10 +74,12 @@ class Channel {
|
|
|
74
74
|
* @param {number} [options.limit] - Number of messages to fetch
|
|
75
75
|
* @param {string} [options.before] - Fetch messages before this message ID
|
|
76
76
|
* @param {string} [options.after] - Fetch messages after this message ID
|
|
77
|
-
* @returns {Promise<
|
|
77
|
+
* @returns {Promise<Message[]>} Array of message instances
|
|
78
78
|
*/
|
|
79
79
|
async fetchMessages(options = {}) {
|
|
80
|
-
|
|
80
|
+
const data = await this.rest.fetchMessages(this.id, options);
|
|
81
|
+
if (!Array.isArray(data)) return data;
|
|
82
|
+
return data.map((msg) => new Message(this.client, msg));
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
/**
|
package/src/classes/Client.js
CHANGED
|
@@ -248,10 +248,12 @@ class Client extends EventEmitter {
|
|
|
248
248
|
* @param {number} [options.limit] - Number of messages to fetch
|
|
249
249
|
* @param {string} [options.before] - Fetch messages before this message ID
|
|
250
250
|
* @param {string} [options.after] - Fetch messages after this message ID
|
|
251
|
-
* @returns {Promise<
|
|
251
|
+
* @returns {Promise<Message[]>} Array of message instances
|
|
252
252
|
*/
|
|
253
253
|
async fetchMessages(channelId, options = {}) {
|
|
254
|
-
|
|
254
|
+
const data = await this.rest.fetchMessages(channelId, options);
|
|
255
|
+
if (!Array.isArray(data)) return data;
|
|
256
|
+
return data.map((msg) => new Message(this, msg));
|
|
255
257
|
}
|
|
256
258
|
|
|
257
259
|
/**
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
* @param {RestManager} rest - The REST manager instance
|
|
4
4
|
* @param {string} channelId - The channel ID
|
|
5
5
|
* @param {string} messageId - The message ID
|
|
6
|
-
* @param {string} emoji - The emoji to react with (unicode or
|
|
6
|
+
* @param {string|object} emoji - The emoji to react with (unicode, custom emoji string, or emoji object)
|
|
7
7
|
* @returns {Promise<void>}
|
|
8
8
|
*/
|
|
9
9
|
async function react(rest, channelId, messageId, emoji) {
|
|
10
|
+
let emojiStr = emoji;
|
|
11
|
+
if (emoji && typeof emoji === "object") {
|
|
12
|
+
emojiStr = emoji.id ? `${emoji.name}:${emoji.id}` : emoji.name;
|
|
13
|
+
}
|
|
10
14
|
// Encode emoji for URL (e.g., 😀 -> %F0%9F%98%80, or custom:123 -> custom%3A123)
|
|
11
|
-
const encodedEmoji = encodeURIComponent(
|
|
15
|
+
const encodedEmoji = encodeURIComponent(emojiStr);
|
|
12
16
|
return await rest.request(
|
|
13
17
|
`/channels/${channelId}/messages/${messageId}/reactions/${encodedEmoji}/@me`,
|
|
14
18
|
{
|
|
@@ -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
|
-
|
|
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 = [];
|