djs-selfbot-v13 3.1.6 → 3.1.7

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 (148) hide show
  1. package/README.md +31 -16
  2. package/package.json +15 -8
  3. package/src/client/BaseClient.js +3 -2
  4. package/src/client/Client.js +539 -187
  5. package/src/client/actions/Action.js +13 -18
  6. package/src/client/actions/ActionsManager.js +1 -7
  7. package/src/client/actions/AutoModerationActionExecution.js +0 -1
  8. package/src/client/actions/AutoModerationRuleCreate.js +0 -1
  9. package/src/client/actions/AutoModerationRuleDelete.js +0 -1
  10. package/src/client/actions/AutoModerationRuleUpdate.js +0 -1
  11. package/src/client/actions/InteractionCreate.js +115 -0
  12. package/src/client/actions/MessageCreate.js +4 -0
  13. package/src/client/actions/PresenceUpdate.js +16 -17
  14. package/src/client/websocket/WebSocketManager.js +31 -11
  15. package/src/client/websocket/WebSocketShard.js +38 -39
  16. package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +23 -0
  17. package/src/client/websocket/handlers/CALL_CREATE.js +3 -3
  18. package/src/client/websocket/handlers/CALL_DELETE.js +2 -2
  19. package/src/client/websocket/handlers/CALL_UPDATE.js +2 -2
  20. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +13 -16
  21. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
  22. package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +11 -0
  23. package/src/client/websocket/handlers/GUILD_CREATE.js +0 -7
  24. package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +55 -0
  25. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
  26. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
  27. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
  28. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
  29. package/src/client/websocket/handlers/INTERACTION_CREATE.js +16 -0
  30. package/src/client/websocket/handlers/INTERACTION_FAILURE.js +18 -0
  31. package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +0 -1
  32. package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +30 -0
  33. package/src/client/websocket/handlers/MESSAGE_ACK.js +16 -0
  34. package/src/client/websocket/handlers/READY.js +137 -47
  35. package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +5 -7
  36. package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +4 -6
  37. package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +9 -32
  38. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
  39. package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +8 -2
  40. package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
  41. package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +5 -1
  42. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
  43. package/src/client/websocket/handlers/index.js +20 -15
  44. package/src/errors/Messages.js +69 -24
  45. package/src/index.js +43 -12
  46. package/src/managers/ApplicationCommandManager.js +12 -9
  47. package/src/managers/ApplicationCommandPermissionsManager.js +11 -3
  48. package/src/managers/ChannelManager.js +4 -2
  49. package/src/managers/ClientUserSettingManager.js +279 -161
  50. package/src/managers/DeveloperPortalManager.js +104 -0
  51. package/src/managers/GuildApplicationCommandManager.js +28 -0
  52. package/src/managers/GuildBanManager.js +1 -1
  53. package/src/managers/GuildChannelManager.js +0 -2
  54. package/src/managers/GuildFolderManager.js +24 -0
  55. package/src/managers/GuildForumThreadManager.js +28 -22
  56. package/src/managers/GuildMemberManager.js +216 -40
  57. package/src/managers/GuildSettingManager.js +15 -22
  58. package/src/managers/MessageManager.js +44 -42
  59. package/src/managers/PermissionOverwriteManager.js +1 -1
  60. package/src/managers/ReactionUserManager.js +5 -5
  61. package/src/managers/RelationshipManager.js +74 -81
  62. package/src/managers/SessionManager.js +57 -0
  63. package/src/managers/ThreadManager.js +45 -12
  64. package/src/managers/ThreadMemberManager.js +1 -1
  65. package/src/managers/UserManager.js +10 -6
  66. package/src/rest/APIRequest.js +20 -42
  67. package/src/rest/CaptchaSolver.js +132 -0
  68. package/src/rest/DiscordAPIError.js +16 -17
  69. package/src/rest/RESTManager.js +21 -1
  70. package/src/rest/RequestHandler.js +21 -35
  71. package/src/structures/ApplicationCommand.js +456 -19
  72. package/src/structures/ApplicationRoleConnectionMetadata.js +0 -3
  73. package/src/structures/AutoModerationRule.js +5 -5
  74. package/src/structures/AutocompleteInteraction.js +0 -1
  75. package/src/structures/BaseGuildTextChannel.js +12 -10
  76. package/src/structures/BaseGuildVoiceChannel.js +18 -16
  77. package/src/structures/{CallState.js → Call.js} +12 -17
  78. package/src/structures/CategoryChannel.js +0 -2
  79. package/src/structures/Channel.js +3 -2
  80. package/src/structures/ClientApplication.js +204 -0
  81. package/src/structures/ClientPresence.js +8 -12
  82. package/src/structures/ClientUser.js +336 -117
  83. package/src/structures/ContextMenuInteraction.js +1 -1
  84. package/src/structures/DMChannel.js +92 -29
  85. package/src/structures/DeveloperPortalApplication.js +520 -0
  86. package/src/structures/ForumChannel.js +10 -0
  87. package/src/structures/Guild.js +271 -135
  88. package/src/structures/GuildAuditLogs.js +5 -0
  89. package/src/structures/GuildChannel.js +2 -16
  90. package/src/structures/GuildFolder.js +75 -0
  91. package/src/structures/GuildMember.js +145 -27
  92. package/src/structures/Interaction.js +62 -1
  93. package/src/structures/InteractionResponse.js +114 -0
  94. package/src/structures/Invite.js +52 -35
  95. package/src/structures/Message.js +202 -222
  96. package/src/structures/MessageAttachment.js +0 -11
  97. package/src/structures/MessageButton.js +67 -1
  98. package/src/structures/MessageEmbed.js +1 -1
  99. package/src/structures/MessageMentions.js +2 -3
  100. package/src/structures/MessagePayload.js +46 -4
  101. package/src/structures/MessageReaction.js +1 -1
  102. package/src/structures/MessageSelectMenu.js +252 -1
  103. package/src/structures/Modal.js +180 -75
  104. package/src/structures/PartialGroupDMChannel.js +433 -0
  105. package/src/structures/Presence.js +2 -2
  106. package/src/structures/RichPresence.js +34 -14
  107. package/src/structures/Role.js +2 -18
  108. package/src/structures/SelectMenuInteraction.js +151 -2
  109. package/src/structures/Session.js +81 -0
  110. package/src/structures/Team.js +49 -0
  111. package/src/structures/TextInputComponent.js +70 -0
  112. package/src/structures/ThreadChannel.js +19 -0
  113. package/src/structures/User.js +345 -117
  114. package/src/structures/UserContextMenuInteraction.js +2 -2
  115. package/src/structures/VoiceState.js +39 -74
  116. package/src/structures/WebEmbed.js +52 -38
  117. package/src/structures/Webhook.js +11 -17
  118. package/src/structures/interfaces/Application.js +23 -146
  119. package/src/structures/interfaces/TextBasedChannel.js +256 -411
  120. package/src/util/ApplicationFlags.js +1 -1
  121. package/src/util/Constants.js +284 -106
  122. package/src/util/Formatters.js +2 -16
  123. package/src/util/LimitedCollection.js +1 -1
  124. package/src/util/Options.js +68 -48
  125. package/src/util/Permissions.js +0 -5
  126. package/src/util/PurchasedFlags.js +0 -2
  127. package/src/util/RemoteAuth.js +356 -221
  128. package/src/util/Sweepers.js +1 -1
  129. package/src/util/Util.js +36 -76
  130. package/src/util/Voice.js +1456 -0
  131. package/src/util/arRPC/index.js +229 -0
  132. package/src/util/arRPC/process/detectable.json +1 -0
  133. package/src/util/arRPC/process/index.js +102 -0
  134. package/src/util/arRPC/process/native/index.js +5 -0
  135. package/src/util/arRPC/process/native/linux.js +37 -0
  136. package/src/util/arRPC/process/native/win32.js +25 -0
  137. package/src/util/arRPC/transports/ipc.js +281 -0
  138. package/src/util/arRPC/transports/websocket.js +128 -0
  139. package/typings/enums.d.ts +73 -18
  140. package/typings/index.d.ts +1249 -897
  141. package/typings/rawDataTypes.d.ts +9 -68
  142. package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +0 -78
  143. package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +0 -12
  144. package/src/managers/UserNoteManager.js +0 -53
  145. package/src/structures/GroupDMChannel.js +0 -387
  146. package/src/util/AttachmentFlags.js +0 -38
  147. package/src/util/InviteFlags.js +0 -29
  148. package/src/util/RoleFlags.js +0 -37
@@ -18,6 +18,7 @@ const {
18
18
  TimestampStyles,
19
19
  underscore,
20
20
  userMention,
21
+ chatInputApplicationCommandMention,
21
22
  } = require('@discordjs/builders');
22
23
 
23
24
  /**
@@ -65,22 +66,7 @@ Formatters.channelMention = channelMention;
65
66
  * @returns {string}
66
67
  * @static
67
68
  */
68
- Formatters.chatInputApplicationCommandMention = function chatInputApplicationCommandMention(
69
- commandName,
70
- subcommandGroupOrSubOrId,
71
- subcommandNameOrId,
72
- commandId,
73
- ) {
74
- if (typeof commandId !== 'undefined') {
75
- return `</${commandName} ${subcommandGroupOrSubOrId} ${subcommandNameOrId}:${commandId}>`;
76
- }
77
-
78
- if (typeof subcommandNameOrId !== 'undefined') {
79
- return `</${commandName} ${subcommandGroupOrSubOrId}:${subcommandNameOrId}>`;
80
- }
81
-
82
- return `</${commandName}:${subcommandGroupOrSubOrId}>`;
83
- };
69
+ Formatters.chatInputApplicationCommandMention = chatInputApplicationCommandMention;
84
70
 
85
71
  /**
86
72
  * Wraps the content inside a code block with an optional language.
@@ -10,7 +10,7 @@ const { TypeError } = require('../errors/DJSError.js');
10
10
  * @typedef {Function} SweepFilter
11
11
  * @param {LimitedCollection} collection The collection being swept
12
12
  * @returns {Function|null} Return `null` to skip sweeping, otherwise a function passed to `sweep()`,
13
- * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/stable/Collection:Class#sweep)}
13
+ * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/stable/Collection:Class?scrollTo=sweep)}
14
14
  * for the definition of this function.
15
15
  */
16
16
 
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const { UserAgent } = require('./Constants');
3
+ const JSONBig = require('json-bigint');
4
4
  const Intents = require('./Intents');
5
-
5
+ const { defaultUA } = require('../util/Constants');
6
6
  /**
7
7
  * Rate limit data
8
8
  * @typedef {Object} RateLimitData
@@ -28,33 +28,28 @@ const Intents = require('./Intents');
28
28
  * @returns {Collection} A Collection used to store the cache of the manager.
29
29
  */
30
30
 
31
- /**
32
- * @typedef {Function} CaptchaSolver
33
- * @param {Captcha} captcha Discord Captcha
34
- * @param {string} UserAgent Current UserAgent
35
- * @returns {Promise<string>} HCaptcha Token
36
- * @example
37
- * const Captcha = require("2captcha")
38
- * // A new 'solver' instance with our API key
39
- * const solver = new Captcha.Solver("<Your 2captcha api key>")
40
- * function solveCaptcha(captcha, UA) {
41
- * return solver.hcaptcha(captcha.captcha_sitekey, 'discord.com', {
42
- * invisible: 1,
43
- * userAgent: UA,
44
- * data: captcha.captcha_rqdata,
45
- * }).then(res => res.data)
46
- * }
47
- */
48
-
49
31
  /**
50
32
  * Options for a client.
51
33
  * @typedef {Object} ClientOptions
52
- * @property {number} [DMChannelVoiceStatusSync=0] The amount of time in milliseconds that the Client to register the event with each DM channel (0=Disable)
53
- * @property {number} [captchaRetryLimit=3] Captcha retry limit
54
- * @property {CaptchaSolver} [captchaSolver] Captcha Solver
34
+ * @property {number|number[]|string} [shards] The shard's id to run, or an array of shard ids. If not specified,
35
+ * the client will spawn {@link ClientOptions#shardCount} shards. If set to `auto`, it will fetch the
36
+ * recommended amount of shards from Discord and spawn that amount
55
37
  * @property {number} [closeTimeout=5000] The amount of time in milliseconds to wait for the close frame to be received
56
- * from the WebSocket.
57
- * <info>Don't have this too high/low. It's best to have it between 2000-6000 ms.</info>
38
+ * from the WebSocket. Don't have this too high/low. Its best to have it between 2_000-6_000 ms.
39
+ * @property {boolean} [checkUpdate=true] Display module update information on the screen
40
+ * @property {boolean} [syncStatus=true] Sync state with Discord Client
41
+ * @property {boolean} [patchVoice=false] Automatically patch @discordjs/voice module (support for call)
42
+ * @property {string} [captchaService=null] Captcha service to use for solving captcha {@link captchaServices}
43
+ * @property {string} [captchaKey=null] Captcha service key
44
+ * @property {string} [captchaRetryLimit=3] Captcha retry limit
45
+ * @property {string} [captchaWithProxy=false] Whether to use proxy for captcha solving
46
+ * @property {string} [password=null] Your Discord account password
47
+ * @property {boolean} [usingNewAttachmentAPI=true] Use new attachment API
48
+ * @property {string} [interactionTimeout=15000] The amount of time in milliseconds to wait for an interaction response, before rejecting
49
+ * @property {boolean} [autoRedeemNitro=false] Automaticlly redeems nitro codes <NOTE: there is no cooldown on the auto redeem>
50
+ * @property {string} [proxy] Proxy to use for the WebSocket + REST connection (proxy-agent uri type) {@link https://www.npmjs.com/package/proxy-agent}.
51
+ * @property {boolean} [DMSync=false] Automatically synchronize call status (DM and group) at startup (event synchronization) [Warning: May cause rate limit to gateway)
52
+ * @property {number} [shardCount=1] The total amount of shards used by all processes of this bot
58
53
  * (e.g. recommended shard count, shard count of the ShardingManager)
59
54
  * @property {CacheFactory} [makeCache] Function to create a cache.
60
55
  * You can use your own function, or the {@link Options} class to customize the Collection used for the cache.
@@ -89,12 +84,25 @@ const Intents = require('./Intents');
89
84
  * @property {number} [retryLimit=1] How many times to retry on 5XX errors
90
85
  * (Infinity for an indefinite amount of retries)
91
86
  * @property {boolean} [failIfNotExists=true] Default value for {@link ReplyMessageOptions#failIfNotExists}
92
- * @property {PresenceData} [presence={ status: 'online', since: 0, activities: [], afk: false }] Presence data to use upon login
93
- * @property {number} [waitGuildTimeout=15_000] Time in milliseconds that Clients with the GUILDS intent should wait for
94
- * missing guilds to be received before starting the bot. If not specified, the default is 15 seconds.
87
+ * @property {string[]} [userAgentSuffix] An array of additional bot info to be appended to the end of the required
88
+ * [User Agent](https://discord.com/developers/docs/reference#user-agent) header
89
+ * @property {PresenceData} [presence={}] Presence data to use upon login
90
+ * @property {IntentsResolvable} [intents=131071] Intents to enable for this connection (but not using)
91
+ * @property {number} [waitGuildTimeout=15000] Time in milliseconds that Clients with the GUILDS intent should wait for
92
+ * @property {number} [messageCreateEventGuildTimeout=100] Time in milliseconds that Clients to register for messages with each guild
93
+ * missing guilds to be received before starting the bot. If not specified, the default is 100 milliseconds.
95
94
  * @property {SweeperOptions} [sweepers={}] Options for cache sweeping
96
95
  * @property {WebsocketOptions} [ws] Options for the WebSocket
97
96
  * @property {HTTPOptions} [http] HTTP options
97
+ * @property {CustomCaptchaSolver} [captchaSolver] Function to solve a captcha (custom)
98
+ */
99
+
100
+ /**
101
+ * Function to solve a captcha
102
+ * @typedef {function} CustomCaptchaSolver
103
+ * @param {Captcha} captcha The captcha to solve
104
+ * @param {string} userAgent The user agent to use for the request
105
+ * @returns {Promise<string>} hcaptcha token
98
106
  */
99
107
 
100
108
  /**
@@ -116,7 +124,6 @@ const Intents = require('./Intents');
116
124
  /**
117
125
  * WebSocket options (these are left as snake_case to match the API)
118
126
  * @typedef {Object} WebsocketOptions
119
- * @property {AgentOptions} [agent={}] HTTPS Agent options (WS Proxy)
120
127
  * @property {boolean} [compress=false] Whether to compress data sent on the connection
121
128
  * @property {WebSocketProperties} [properties] Properties to identify the client with
122
129
  */
@@ -151,13 +158,24 @@ class Options extends null {
151
158
  */
152
159
  static createDefault() {
153
160
  return {
154
- DMChannelVoiceStatusSync: 0,
155
- captchaRetryLimit: 3,
156
- captchaSolver: () => Promise.reject(new Error('CAPTCHA_SOLVER_NOT_IMPLEMENTED')),
161
+ jsonTransformer: object => JSONBig.stringify(object),
162
+ captchaSolver: captcha => Promise.reject(new Error('CAPTCHA_SOLVER_NOT_IMPLEMENTED', captcha)),
157
163
  closeTimeout: 5_000,
164
+ checkUpdate: true,
165
+ syncStatus: true,
166
+ autoRedeemNitro: false,
167
+ captchaService: '',
168
+ captchaKey: null,
169
+ captchaRetryLimit: 3,
170
+ captchaWithProxy: false,
171
+ DMSync: false,
172
+ patchVoice: false,
173
+ password: null,
174
+ usingNewAttachmentAPI: true,
175
+ interactionTimeout: 15_000,
158
176
  waitGuildTimeout: 15_000,
177
+ messageCreateEventGuildTimeout: 100,
159
178
  shardCount: 1,
160
- shards: [0],
161
179
  makeCache: this.cacheWithLimits(this.defaultMakeCacheSettings),
162
180
  messageCacheLifetime: 0,
163
181
  messageSweepInterval: 0,
@@ -170,25 +188,26 @@ class Options extends null {
170
188
  retryLimit: 1,
171
189
  restTimeOffset: 500,
172
190
  restSweepInterval: 60,
173
- failIfNotExists: true,
191
+ failIfNotExists: false,
192
+ userAgentSuffix: [],
174
193
  presence: { status: 'online', since: 0, activities: [], afk: false },
175
194
  sweepers: {},
195
+ proxy: '',
176
196
  ws: {
177
- capabilities: 0, // https://discord-userdoccers.vercel.app/topics/gateway#gateway-capabilities
197
+ // eslint-disable-next-line no-undef
198
+ // capabilities: 16381,
178
199
  properties: {
179
200
  os: 'Windows',
180
- browser: 'Chrome',
181
- device: '',
182
- system_locale: 'vi-VN',
183
- browser_user_agent: UserAgent,
184
- browser_version: '108.0.5359.215',
185
- os_version: '10',
186
- referrer: '',
187
- referring_domain: '',
188
- referrer_current: '',
189
- referring_domain_current: '',
201
+ browser: 'Discord Client',
190
202
  release_channel: 'stable',
191
- client_build_number: 261141,
203
+ client_version: '1.0.9015',
204
+ os_version: '10.0.19045',
205
+ os_arch: 'x64',
206
+ system_locale: 'en-US',
207
+ browser_user_agent: defaultUA,
208
+ browser_version: '22.3.12',
209
+ client_build_number: 213510,
210
+ native_build_number: 34898,
192
211
  client_event_source: null,
193
212
  },
194
213
  compress: false,
@@ -202,12 +221,11 @@ class Options extends null {
202
221
  api_code_version: 0,
203
222
  },
204
223
  version: 9,
205
- agent: {},
206
224
  },
207
225
  http: {
208
226
  agent: {},
209
227
  headers: {
210
- 'User-Agent': UserAgent,
228
+ 'User-Agent': defaultUA,
211
229
  },
212
230
  version: 9,
213
231
  api: 'https://discord.com/api',
@@ -308,6 +326,7 @@ class Options extends null {
308
326
  static get defaultMakeCacheSettings() {
309
327
  return {
310
328
  MessageManager: 200,
329
+ /*
311
330
  ChannelManager: {
312
331
  sweepInterval: 3600,
313
332
  sweepFilter: require('./Util').archivedThreadSweepFilter(),
@@ -320,6 +339,7 @@ class Options extends null {
320
339
  sweepInterval: 3600,
321
340
  sweepFilter: require('./Util').archivedThreadSweepFilter(),
322
341
  },
342
+ */
323
343
  };
324
344
  }
325
345
  }
@@ -110,9 +110,6 @@ class Permissions extends BitField {
110
110
  * * `MODERATE_MEMBERS`
111
111
  * * `VIEW_CREATOR_MONETIZATION_ANALYTICS`
112
112
  * * `USE_SOUNDBOARD`
113
- * * `SEND_VOICE_MESSAGES`
114
- * * `USE_CLYDE_AI`
115
- * * `SET_VOICE_CHANNEL_STATUS`
116
113
  * @type {Object<string, bigint>}
117
114
  * @see {@link https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags}
118
115
  */
@@ -164,8 +161,6 @@ Permissions.FLAGS = {
164
161
  VIEW_CREATOR_MONETIZATION_ANALYTICS: 1n << 41n,
165
162
  USE_SOUNDBOARD: 1n << 42n,
166
163
  SEND_VOICE_MESSAGES: 1n << 46n,
167
- USE_CLYDE_AI: 1n << 47n,
168
- SET_VOICE_CHANNEL_STATUS: 1n << 48n,
169
164
  };
170
165
 
171
166
  /**
@@ -20,14 +20,12 @@ class PurchasedFlags extends BitField {}
20
20
  * * `NITRO_CLASSIC`
21
21
  * * `NITRO`
22
22
  * * `GUILD_BOOST`
23
- * * `NITRO_BASIC`
24
23
  * @type {Object}
25
24
  */
26
25
  PurchasedFlags.FLAGS = {
27
26
  NITRO_CLASSIC: 1 << 0,
28
27
  NITRO: 1 << 1,
29
28
  GUILD_BOOST: 1 << 2,
30
- NITRO_BASIC: 1 << 3,
31
29
  };
32
30
 
33
31
  module.exports = PurchasedFlags;