djs-selfbot-v13 3.1.7 → 3.2.2
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/README.md +18 -35
- package/package.json +85 -100
- package/src/client/BaseClient.js +3 -4
- package/src/client/Client.js +249 -530
- package/src/client/actions/Action.js +18 -13
- package/src/client/actions/ActionsManager.js +7 -1
- package/src/client/actions/AutoModerationActionExecution.js +1 -0
- package/src/client/actions/AutoModerationRuleCreate.js +1 -0
- package/src/client/actions/AutoModerationRuleDelete.js +1 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +1 -0
- package/src/client/actions/GuildMemberRemove.js +0 -1
- package/src/client/actions/GuildMemberUpdate.js +0 -1
- package/src/client/actions/MessageCreate.js +0 -4
- package/src/client/actions/PresenceUpdate.js +17 -16
- package/src/client/websocket/WebSocketManager.js +11 -31
- package/src/client/websocket/WebSocketShard.js +39 -38
- package/src/client/websocket/handlers/CALL_CREATE.js +3 -3
- package/src/client/websocket/handlers/CALL_DELETE.js +2 -2
- package/src/client/websocket/handlers/CALL_UPDATE.js +2 -2
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +16 -13
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
- package/src/client/websocket/handlers/GUILD_CREATE.js +19 -13
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +0 -1
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.js +22 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.js +12 -0
- package/src/client/websocket/handlers/READY.js +90 -140
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +7 -5
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +32 -9
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +2 -8
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
- package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +78 -0
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +1 -5
- package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -0
- package/src/client/websocket/handlers/index.js +17 -20
- package/src/errors/Messages.js +25 -69
- package/src/index.js +13 -43
- package/src/managers/ApplicationCommandManager.js +9 -12
- package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
- package/src/managers/ChannelManager.js +2 -3
- package/src/managers/ClientUserSettingManager.js +162 -280
- package/src/managers/GuildBanManager.js +47 -1
- package/src/managers/GuildChannelManager.js +2 -16
- package/src/managers/GuildForumThreadManager.js +24 -30
- package/src/managers/GuildManager.js +1 -1
- package/src/managers/GuildMemberManager.js +50 -222
- package/src/managers/GuildSettingManager.js +22 -15
- package/src/managers/MessageManager.js +42 -44
- package/src/managers/PermissionOverwriteManager.js +1 -1
- package/src/managers/ReactionUserManager.js +5 -5
- package/src/managers/RelationshipManager.js +83 -76
- package/src/managers/ThreadManager.js +12 -45
- package/src/managers/ThreadMemberManager.js +1 -1
- package/src/managers/UserManager.js +6 -10
- package/src/managers/UserNoteManager.js +53 -0
- package/src/rest/APIRequest.js +48 -20
- package/src/rest/DiscordAPIError.js +17 -16
- package/src/rest/RESTManager.js +1 -21
- package/src/rest/RequestHandler.js +35 -21
- package/src/structures/ApplicationCommand.js +19 -456
- package/src/structures/ApplicationRoleConnectionMetadata.js +3 -0
- package/src/structures/AutoModerationRule.js +5 -5
- package/src/structures/AutocompleteInteraction.js +1 -0
- package/src/structures/BaseGuildTextChannel.js +10 -12
- package/src/structures/BaseGuildVoiceChannel.js +16 -18
- package/src/structures/{Call.js → CallState.js} +17 -12
- package/src/structures/CategoryChannel.js +2 -0
- package/src/structures/Channel.js +2 -3
- package/src/structures/ClientPresence.js +20 -19
- package/src/structures/ClientUser.js +117 -338
- package/src/structures/ContextMenuInteraction.js +1 -1
- package/src/structures/DMChannel.js +29 -92
- package/src/structures/ForumChannel.js +0 -10
- package/src/structures/GroupDMChannel.js +387 -0
- package/src/structures/Guild.js +135 -271
- package/src/structures/GuildAuditLogs.js +0 -5
- package/src/structures/GuildChannel.js +16 -2
- package/src/structures/GuildMember.js +27 -145
- package/src/structures/Interaction.js +1 -62
- package/src/structures/Invite.js +35 -52
- package/src/structures/Message.js +220 -203
- package/src/structures/MessageAttachment.js +11 -0
- package/src/structures/MessageButton.js +1 -67
- package/src/structures/MessageEmbed.js +1 -1
- package/src/structures/MessageMentions.js +3 -2
- package/src/structures/MessagePayload.js +6 -46
- package/src/structures/MessagePoll.js +238 -0
- package/src/structures/MessageReaction.js +1 -1
- package/src/structures/MessageSelectMenu.js +1 -252
- package/src/structures/Modal.js +70 -188
- package/src/structures/Presence.js +787 -129
- package/src/structures/Role.js +18 -2
- package/src/structures/SelectMenuInteraction.js +2 -151
- package/src/structures/Team.js +0 -49
- package/src/structures/TextInputComponent.js +0 -70
- package/src/structures/ThreadChannel.js +0 -19
- package/src/structures/User.js +145 -339
- package/src/structures/UserContextMenuInteraction.js +2 -2
- package/src/structures/VoiceState.js +74 -39
- package/src/structures/WebEmbed.js +38 -52
- package/src/structures/Webhook.js +17 -11
- package/src/structures/interfaces/Application.js +146 -23
- package/src/structures/interfaces/TextBasedChannel.js +409 -256
- package/src/util/ApplicationFlags.js +1 -1
- package/src/util/AttachmentFlags.js +38 -0
- package/src/util/Constants.js +120 -285
- package/src/util/Formatters.js +16 -2
- package/src/util/InviteFlags.js +29 -0
- package/src/util/LimitedCollection.js +1 -1
- package/src/util/Options.js +48 -74
- package/src/util/Permissions.js +15 -0
- package/src/util/PurchasedFlags.js +2 -0
- package/src/util/RemoteAuth.js +221 -356
- package/src/util/RoleFlags.js +37 -0
- package/src/util/Sweepers.js +1 -1
- package/src/util/Util.js +158 -32
- package/typings/enums.d.ts +24 -73
- package/typings/index.d.ts +978 -1288
- package/typings/rawDataTypes.d.ts +68 -9
- package/src/client/actions/InteractionCreate.js +0 -115
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +0 -23
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +0 -11
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +0 -55
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.js +0 -16
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +0 -18
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +0 -30
- package/src/client/websocket/handlers/MESSAGE_ACK.js +0 -16
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
- package/src/managers/DeveloperPortalManager.js +0 -104
- package/src/managers/GuildApplicationCommandManager.js +0 -28
- package/src/managers/GuildFolderManager.js +0 -24
- package/src/managers/SessionManager.js +0 -57
- package/src/rest/CaptchaSolver.js +0 -132
- package/src/structures/ClientApplication.js +0 -204
- package/src/structures/DeveloperPortalApplication.js +0 -520
- package/src/structures/GuildFolder.js +0 -75
- package/src/structures/InteractionResponse.js +0 -114
- package/src/structures/PartialGroupDMChannel.js +0 -433
- package/src/structures/RichPresence.js +0 -722
- package/src/structures/Session.js +0 -81
- package/src/util/Voice.js +0 -1456
- package/src/util/arRPC/index.js +0 -229
- package/src/util/arRPC/process/detectable.json +0 -1
- package/src/util/arRPC/process/index.js +0 -102
- package/src/util/arRPC/process/native/index.js +0 -5
- package/src/util/arRPC/process/native/linux.js +0 -37
- package/src/util/arRPC/process/native/win32.js +0 -25
- package/src/util/arRPC/transports/ipc.js +0 -281
- package/src/util/arRPC/transports/websocket.js +0 -128
|
@@ -25,7 +25,7 @@ class DiscordAPIError extends Error {
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* HTTP error code returned by Discord
|
|
28
|
-
* @type {number
|
|
28
|
+
* @type {number}
|
|
29
29
|
*/
|
|
30
30
|
this.code = error.code;
|
|
31
31
|
|
|
@@ -35,21 +35,6 @@ class DiscordAPIError extends Error {
|
|
|
35
35
|
*/
|
|
36
36
|
this.httpStatus = status;
|
|
37
37
|
|
|
38
|
-
/**
|
|
39
|
-
* @typedef {Object} Captcha
|
|
40
|
-
* @property {Array<string>} captcha_key ['message']
|
|
41
|
-
* @property {string} captcha_sitekey Captcha sitekey (hcaptcha)
|
|
42
|
-
* @property {string} captcha_service hcaptcha
|
|
43
|
-
* @property {string} [captcha_rqdata]
|
|
44
|
-
* @property {string} [captcha_rqtoken]
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Captcha response data if the request requires a captcha
|
|
49
|
-
* @type {Captcha | null}
|
|
50
|
-
*/
|
|
51
|
-
this.captcha = error?.captcha_service ? error : null;
|
|
52
|
-
|
|
53
38
|
/**
|
|
54
39
|
* The data associated with the request that caused this error
|
|
55
40
|
* @type {HTTPErrorData}
|
|
@@ -57,6 +42,7 @@ class DiscordAPIError extends Error {
|
|
|
57
42
|
this.requestData = {
|
|
58
43
|
json: request.options.data,
|
|
59
44
|
files: request.options.files ?? [],
|
|
45
|
+
headers: request.options.headers,
|
|
60
46
|
};
|
|
61
47
|
|
|
62
48
|
/**
|
|
@@ -64,6 +50,21 @@ class DiscordAPIError extends Error {
|
|
|
64
50
|
* @type {number}
|
|
65
51
|
*/
|
|
66
52
|
this.retries = request.retries;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {Object} Captcha
|
|
56
|
+
* @property {Array<string>} captcha_key ['message']
|
|
57
|
+
* @property {string} captcha_sitekey Captcha sitekey (hcaptcha)
|
|
58
|
+
* @property {string} captcha_service hcaptcha
|
|
59
|
+
* @property {string} [captcha_rqdata]
|
|
60
|
+
* @property {string} [captcha_rqtoken]
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Captcha response data if the request requires a captcha
|
|
65
|
+
* @type {Captcha | null}
|
|
66
|
+
*/
|
|
67
|
+
this.captcha = error?.captcha_service ? error : null;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
package/src/rest/RESTManager.js
CHANGED
|
@@ -4,7 +4,6 @@ const { setInterval } = require('node:timers');
|
|
|
4
4
|
const { Collection } = require('@discordjs/collection');
|
|
5
5
|
const APIRequest = require('./APIRequest');
|
|
6
6
|
const routeBuilder = require('./APIRouter');
|
|
7
|
-
const CaptchaSolver = require('./CaptchaSolver');
|
|
8
7
|
const RequestHandler = require('./RequestHandler');
|
|
9
8
|
const { Error } = require('../errors');
|
|
10
9
|
const { Endpoints } = require('../util/Constants');
|
|
@@ -23,17 +22,6 @@ class RESTManager {
|
|
|
23
22
|
this.handlers.sweep(handler => handler._inactive);
|
|
24
23
|
}, client.options.restSweepInterval * 1_000).unref();
|
|
25
24
|
}
|
|
26
|
-
this.captchaService = null;
|
|
27
|
-
this.setup();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
setup() {
|
|
31
|
-
this.captchaService = new CaptchaSolver(
|
|
32
|
-
this.client.options.captchaService,
|
|
33
|
-
this.client.options.captchaKey,
|
|
34
|
-
this.client.options.captchaSolver,
|
|
35
|
-
this.client.options.captchaWithProxy ? this.client.options.proxy : '',
|
|
36
|
-
);
|
|
37
25
|
}
|
|
38
26
|
|
|
39
27
|
get api() {
|
|
@@ -41,16 +29,8 @@ class RESTManager {
|
|
|
41
29
|
}
|
|
42
30
|
|
|
43
31
|
getAuth() {
|
|
44
|
-
if ((this.client.token && this.client.user && this.client.user.bot) || this.client.accessToken) {
|
|
45
|
-
return `Bot ${this.client.token}`;
|
|
46
|
-
} else if (this.client.token) {
|
|
47
|
-
return this.client.token;
|
|
48
|
-
}
|
|
49
|
-
/*
|
|
50
|
-
// v13.7
|
|
51
32
|
const token = this.client.token ?? this.client.accessToken;
|
|
52
|
-
if (token) return
|
|
53
|
-
*/
|
|
33
|
+
if (token) return token?.replace(/Bot /g, '');
|
|
54
34
|
throw new Error('TOKEN_MISSING');
|
|
55
35
|
}
|
|
56
36
|
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const { setTimeout } = require('node:timers');
|
|
4
4
|
const { setTimeout: sleep } = require('node:timers/promises');
|
|
5
|
-
const { inspect } = require('util');
|
|
6
5
|
const { AsyncQueue } = require('@sapphire/async-queue');
|
|
7
6
|
const DiscordAPIError = require('./DiscordAPIError');
|
|
8
7
|
const HTTPError = require('./HTTPError');
|
|
9
8
|
const RateLimitError = require('./RateLimitError');
|
|
10
9
|
const {
|
|
11
|
-
Events: { DEBUG, RATE_LIMIT, INVALID_REQUEST_WARNING, API_RESPONSE, API_REQUEST
|
|
10
|
+
Events: { DEBUG, RATE_LIMIT, INVALID_REQUEST_WARNING, API_RESPONSE, API_REQUEST },
|
|
12
11
|
} = require('../util/Constants');
|
|
13
12
|
|
|
14
13
|
const captchaMessage = [
|
|
@@ -19,11 +18,13 @@ const captchaMessage = [
|
|
|
19
18
|
'invalid-response',
|
|
20
19
|
'You need to update your app',
|
|
21
20
|
'response-already-used-error',
|
|
21
|
+
'rqkey-mismatch',
|
|
22
|
+
'sitekey-secret-mismatch',
|
|
22
23
|
];
|
|
23
24
|
|
|
24
25
|
function parseResponse(res) {
|
|
25
26
|
if (res.headers.get('content-type')?.startsWith('application/json')) return res.json();
|
|
26
|
-
return res.arrayBuffer();
|
|
27
|
+
return res.arrayBuffer();
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
function getAPIOffset(serverDate) {
|
|
@@ -354,50 +355,63 @@ class RequestHandler {
|
|
|
354
355
|
let data;
|
|
355
356
|
try {
|
|
356
357
|
data = await parseResponse(res);
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Emitted when a request is blocked by a captcha
|
|
360
|
-
* @event Client#captchaRequired
|
|
361
|
-
* @param {Request} request The request that was blocked
|
|
362
|
-
* @param {Captcha} data The data returned by Discord
|
|
363
|
-
*/
|
|
364
|
-
this.manager.client.emit(CAPTCHA_REQUIRED, request, data);
|
|
365
|
-
}
|
|
358
|
+
// Captcha
|
|
366
359
|
if (
|
|
367
360
|
data?.captcha_service &&
|
|
368
|
-
this.manager.client.options.
|
|
361
|
+
typeof this.manager.client.options.captchaSolver == 'function' &&
|
|
369
362
|
request.retries < this.manager.client.options.captchaRetryLimit &&
|
|
370
363
|
captchaMessage.some(s => data.captcha_key[0].includes(s))
|
|
371
364
|
) {
|
|
372
365
|
// Retry the request after a captcha is solved
|
|
373
366
|
this.manager.client.emit(
|
|
374
367
|
DEBUG,
|
|
375
|
-
`Hit a captcha while executing a request.
|
|
368
|
+
`Hit a captcha while executing a request (${data.captcha_key.join(', ')})
|
|
376
369
|
Method : ${request.method}
|
|
377
370
|
Path : ${request.path}
|
|
378
371
|
Route : ${request.route}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const captcha = await this.manager.captchaService.solve(
|
|
382
|
-
data,
|
|
383
|
-
this.manager.client.options.http.headers['User-Agent'],
|
|
372
|
+
Sitekey : ${data.captcha_sitekey}
|
|
373
|
+
rqToken : ${data.captcha_rqtoken}`,
|
|
384
374
|
);
|
|
385
|
-
|
|
375
|
+
const captcha = await this.manager.client.options.captchaSolver(data, request.fullUserAgent);
|
|
386
376
|
this.manager.client.emit(
|
|
387
377
|
DEBUG,
|
|
388
378
|
`Captcha details:
|
|
389
379
|
Method : ${request.method}
|
|
390
380
|
Path : ${request.path}
|
|
391
381
|
Route : ${request.route}
|
|
392
|
-
Key : ${captcha ? `${captcha.slice(0,
|
|
382
|
+
Key : ${captcha ? `${captcha.slice(0, 120)}...` : '[Captcha not solved]'}
|
|
393
383
|
rqToken : ${data.captcha_rqtoken}`,
|
|
394
384
|
);
|
|
395
385
|
request.retries++;
|
|
396
386
|
return this.execute(request, captcha, data.captcha_rqtoken);
|
|
397
387
|
}
|
|
388
|
+
// Two factor
|
|
389
|
+
if (data?.code && data.code == 60003 && request.options.mfaCode && request.retries < 1) {
|
|
390
|
+
this.manager.client.emit(
|
|
391
|
+
DEBUG,
|
|
392
|
+
`${data.message}
|
|
393
|
+
Method : ${request.method}
|
|
394
|
+
Path : ${request.path}
|
|
395
|
+
Route : ${request.route}
|
|
396
|
+
mfaCode : ${request.options.mfaCode}`,
|
|
397
|
+
);
|
|
398
|
+
// Get ticket
|
|
399
|
+
const mfaData = data.mfa;
|
|
400
|
+
const mfaPost = await this.manager.client.api.mfa.finish.post({
|
|
401
|
+
data: {
|
|
402
|
+
ticket: mfaData.ticket,
|
|
403
|
+
data: request.options.mfaCode,
|
|
404
|
+
mfa_type: 'totp',
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
request.options.mfaToken = mfaPost.token;
|
|
408
|
+
request.retries++;
|
|
409
|
+
return this.execute(request);
|
|
410
|
+
}
|
|
398
411
|
} catch (err) {
|
|
399
412
|
throw new HTTPError(err.message, err.constructor.name, err.status, request);
|
|
400
413
|
}
|
|
414
|
+
|
|
401
415
|
throw new DiscordAPIError(data, res.status, request);
|
|
402
416
|
}
|
|
403
417
|
|