djs-selfbot-v13 1.0.1 → 3.1.4

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 (152) hide show
  1. package/README.md +15 -42
  2. package/package.json +9 -24
  3. package/src/client/BaseClient.js +2 -3
  4. package/src/client/Client.js +187 -539
  5. package/src/client/actions/Action.js +18 -13
  6. package/src/client/actions/ActionsManager.js +7 -1
  7. package/src/client/actions/AutoModerationActionExecution.js +1 -0
  8. package/src/client/actions/AutoModerationRuleCreate.js +1 -0
  9. package/src/client/actions/AutoModerationRuleDelete.js +1 -0
  10. package/src/client/actions/AutoModerationRuleUpdate.js +1 -0
  11. package/src/client/actions/GuildMemberRemove.js +1 -1
  12. package/src/client/actions/GuildMemberUpdate.js +1 -1
  13. package/src/client/actions/MessageCreate.js +0 -4
  14. package/src/client/actions/PresenceUpdate.js +17 -16
  15. package/src/client/websocket/WebSocketManager.js +11 -31
  16. package/src/client/websocket/WebSocketShard.js +39 -38
  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 +16 -13
  21. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
  22. package/src/client/websocket/handlers/GUILD_CREATE.js +7 -0
  23. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -1
  24. package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
  25. package/src/client/websocket/handlers/READY.js +47 -137
  26. package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
  27. package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +6 -4
  28. package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +32 -9
  29. package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +2 -8
  30. package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
  31. package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +78 -0
  32. package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +1 -5
  33. package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -0
  34. package/src/client/websocket/handlers/index.js +15 -20
  35. package/src/errors/Messages.js +24 -69
  36. package/src/index.js +12 -43
  37. package/src/managers/ApplicationCommandManager.js +9 -12
  38. package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
  39. package/src/managers/ChannelManager.js +3 -4
  40. package/src/managers/ClientUserSettingManager.js +161 -279
  41. package/src/managers/GuildBanManager.js +1 -1
  42. package/src/managers/GuildChannelManager.js +2 -0
  43. package/src/managers/GuildForumThreadManager.js +22 -28
  44. package/src/managers/GuildMemberManager.js +40 -216
  45. package/src/managers/GuildSettingManager.js +22 -15
  46. package/src/managers/MessageManager.js +42 -44
  47. package/src/managers/PermissionOverwriteManager.js +1 -1
  48. package/src/managers/ReactionUserManager.js +5 -5
  49. package/src/managers/RelationshipManager.js +81 -74
  50. package/src/managers/ThreadManager.js +12 -45
  51. package/src/managers/ThreadMemberManager.js +1 -1
  52. package/src/managers/UserManager.js +6 -10
  53. package/src/managers/UserNoteManager.js +53 -0
  54. package/src/rest/APIRequest.js +42 -20
  55. package/src/rest/DiscordAPIError.js +17 -16
  56. package/src/rest/RESTManager.js +1 -21
  57. package/src/rest/RequestHandler.js +35 -21
  58. package/src/structures/ApplicationCommand.js +19 -456
  59. package/src/structures/ApplicationRoleConnectionMetadata.js +3 -0
  60. package/src/structures/AutoModerationRule.js +5 -5
  61. package/src/structures/AutocompleteInteraction.js +1 -0
  62. package/src/structures/BaseGuildTextChannel.js +10 -12
  63. package/src/structures/BaseGuildVoiceChannel.js +16 -18
  64. package/src/structures/{Call.js → CallState.js} +17 -12
  65. package/src/structures/CategoryChannel.js +2 -0
  66. package/src/structures/Channel.js +2 -3
  67. package/src/structures/ClientPresence.js +12 -8
  68. package/src/structures/ClientUser.js +124 -310
  69. package/src/structures/ContextMenuInteraction.js +1 -1
  70. package/src/structures/DMChannel.js +29 -92
  71. package/src/structures/ForumChannel.js +0 -10
  72. package/src/structures/GroupDMChannel.js +387 -0
  73. package/src/structures/Guild.js +135 -271
  74. package/src/structures/GuildAuditLogs.js +0 -5
  75. package/src/structures/GuildChannel.js +16 -2
  76. package/src/structures/GuildMember.js +27 -145
  77. package/src/structures/Interaction.js +1 -62
  78. package/src/structures/Invite.js +35 -52
  79. package/src/structures/Message.js +222 -202
  80. package/src/structures/MessageAttachment.js +11 -0
  81. package/src/structures/MessageButton.js +1 -67
  82. package/src/structures/MessageEmbed.js +1 -1
  83. package/src/structures/MessageMentions.js +3 -2
  84. package/src/structures/MessagePayload.js +4 -46
  85. package/src/structures/MessageReaction.js +1 -1
  86. package/src/structures/MessageSelectMenu.js +1 -252
  87. package/src/structures/Modal.js +75 -180
  88. package/src/structures/Presence.js +2 -2
  89. package/src/structures/RichPresence.js +14 -34
  90. package/src/structures/Role.js +18 -2
  91. package/src/structures/SelectMenuInteraction.js +2 -151
  92. package/src/structures/Team.js +0 -49
  93. package/src/structures/TextInputComponent.js +0 -70
  94. package/src/structures/ThreadChannel.js +0 -19
  95. package/src/structures/User.js +117 -345
  96. package/src/structures/UserContextMenuInteraction.js +2 -2
  97. package/src/structures/VoiceState.js +74 -39
  98. package/src/structures/WebEmbed.js +38 -52
  99. package/src/structures/Webhook.js +17 -11
  100. package/src/structures/interfaces/Application.js +146 -23
  101. package/src/structures/interfaces/TextBasedChannel.js +411 -256
  102. package/src/util/ApplicationFlags.js +1 -1
  103. package/src/util/AttachmentFlags.js +38 -0
  104. package/src/util/Constants.js +106 -284
  105. package/src/util/Formatters.js +16 -2
  106. package/src/util/InviteFlags.js +29 -0
  107. package/src/util/LimitedCollection.js +1 -1
  108. package/src/util/Options.js +48 -68
  109. package/src/util/Permissions.js +5 -0
  110. package/src/util/PurchasedFlags.js +2 -0
  111. package/src/util/RemoteAuth.js +221 -356
  112. package/src/util/RoleFlags.js +37 -0
  113. package/src/util/Sweepers.js +1 -1
  114. package/src/util/Util.js +76 -36
  115. package/typings/enums.d.ts +18 -73
  116. package/typings/index.d.ts +874 -1226
  117. package/typings/rawDataTypes.d.ts +68 -9
  118. package/LICENSE +0 -674
  119. package/src/client/actions/InteractionCreate.js +0 -115
  120. package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +0 -23
  121. package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +0 -11
  122. package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +0 -55
  123. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
  124. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
  125. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
  126. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
  127. package/src/client/websocket/handlers/INTERACTION_CREATE.js +0 -16
  128. package/src/client/websocket/handlers/INTERACTION_FAILURE.js +0 -18
  129. package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +0 -30
  130. package/src/client/websocket/handlers/MESSAGE_ACK.js +0 -16
  131. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
  132. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
  133. package/src/managers/DeveloperPortalManager.js +0 -104
  134. package/src/managers/GuildApplicationCommandManager.js +0 -28
  135. package/src/managers/GuildFolderManager.js +0 -24
  136. package/src/managers/SessionManager.js +0 -57
  137. package/src/rest/CaptchaSolver.js +0 -132
  138. package/src/structures/ClientApplication.js +0 -204
  139. package/src/structures/DeveloperPortalApplication.js +0 -520
  140. package/src/structures/GuildFolder.js +0 -75
  141. package/src/structures/InteractionResponse.js +0 -114
  142. package/src/structures/PartialGroupDMChannel.js +0 -433
  143. package/src/structures/Session.js +0 -81
  144. package/src/util/Voice.js +0 -1456
  145. package/src/util/arRPC/index.js +0 -229
  146. package/src/util/arRPC/process/detectable.json +0 -1
  147. package/src/util/arRPC/process/index.js +0 -102
  148. package/src/util/arRPC/process/native/index.js +0 -5
  149. package/src/util/arRPC/process/native/linux.js +0 -37
  150. package/src/util/arRPC/process/native/win32.js +0 -25
  151. package/src/util/arRPC/transports/ipc.js +0 -281
  152. package/src/util/arRPC/transports/websocket.js +0 -128
@@ -1,115 +0,0 @@
1
- 'use strict';
2
-
3
- const process = require('node:process');
4
- const Action = require('./Action');
5
- const AutocompleteInteraction = require('../../structures/AutocompleteInteraction');
6
- const ButtonInteraction = require('../../structures/ButtonInteraction');
7
- const CommandInteraction = require('../../structures/CommandInteraction');
8
- const MessageContextMenuInteraction = require('../../structures/MessageContextMenuInteraction');
9
- const ModalSubmitInteraction = require('../../structures/ModalSubmitInteraction');
10
- const {
11
- ChannelSelectInteraction,
12
- MentionableSelectInteraction,
13
- RoleSelectInteraction,
14
- SelectMenuInteraction,
15
- UserSelectInteraction,
16
- } = require('../../structures/SelectMenuInteraction');
17
- const UserContextMenuInteraction = require('../../structures/UserContextMenuInteraction');
18
- const { Events, InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = require('../../util/Constants');
19
-
20
- let deprecationEmitted = false;
21
-
22
- class InteractionCreateAction extends Action {
23
- handle(data) {
24
- const client = this.client;
25
-
26
- // Resolve and cache partial channels for Interaction#channel getter
27
- const channel = this.getChannel(data);
28
- // Do not emit this for interactions that cache messages that are non-text-based.
29
- let InteractionType;
30
- switch (data.type) {
31
- case InteractionTypes.APPLICATION_COMMAND:
32
- switch (data.data.type) {
33
- case ApplicationCommandTypes.CHAT_INPUT:
34
- InteractionType = CommandInteraction;
35
- break;
36
- case ApplicationCommandTypes.USER:
37
- InteractionType = UserContextMenuInteraction;
38
- break;
39
- case ApplicationCommandTypes.MESSAGE:
40
- InteractionType = MessageContextMenuInteraction;
41
- break;
42
- default:
43
- client.emit(
44
- Events.DEBUG,
45
- `[INTERACTION] Received application command interaction with unknown type: ${data.data.type}`,
46
- );
47
- return;
48
- }
49
- break;
50
- case InteractionTypes.MESSAGE_COMPONENT:
51
- if (channel && !channel.isText()) return;
52
- switch (data.data.component_type) {
53
- case MessageComponentTypes.BUTTON:
54
- InteractionType = ButtonInteraction;
55
- break;
56
- case MessageComponentTypes.STRING_SELECT:
57
- InteractionType = SelectMenuInteraction;
58
- break;
59
- case MessageComponentTypes.CHANNEL_SELECT:
60
- InteractionType = ChannelSelectInteraction;
61
- break;
62
- case MessageComponentTypes.MENTIONABLE_SELECT:
63
- InteractionType = MentionableSelectInteraction;
64
- break;
65
- case MessageComponentTypes.ROLE_SELECT:
66
- InteractionType = RoleSelectInteraction;
67
- break;
68
- case MessageComponentTypes.USER_SELECT:
69
- InteractionType = UserSelectInteraction;
70
- break;
71
- default:
72
- client.emit(
73
- Events.DEBUG,
74
- `[INTERACTION] Received component interaction with unknown type: ${data.data.component_type}`,
75
- );
76
- return;
77
- }
78
- break;
79
- case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE:
80
- InteractionType = AutocompleteInteraction;
81
- break;
82
- case InteractionTypes.MODAL_SUBMIT:
83
- InteractionType = ModalSubmitInteraction;
84
- break;
85
- default:
86
- client.emit(
87
- Events.DEBUG,
88
- `[INTERACTION] Received [BOT] / Send (Selfbot) interactionID ${data.id} with unknown type: ${data.type}`,
89
- );
90
- return;
91
- }
92
-
93
- const interaction = new InteractionType(client, data);
94
-
95
- /**
96
- * Emitted when an interaction is created.
97
- * @event Client#interactionCreate
98
- * @param {InteractionResponseBody | Interaction} interaction The interaction which was created.
99
- */
100
- client.emit(Events.INTERACTION_CREATE, interaction);
101
-
102
- /**
103
- * Emitted when an interaction is created.
104
- * @event Client#interaction
105
- * @param {Interaction} interaction The interaction which was created
106
- * @deprecated Use {@link Client#event:interactionCreate} instead
107
- */
108
- if (client.emit('interaction', interaction) && !deprecationEmitted) {
109
- deprecationEmitted = true;
110
- process.emitWarning('The interaction event is deprecated. Use interactionCreate instead', 'DeprecationWarning');
111
- }
112
- }
113
- }
114
-
115
- module.exports = InteractionCreateAction;
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const { Events } = require('../../../util/Constants');
4
-
5
- module.exports = (client, { d: data }) => {
6
- /**
7
- * @typedef {object} AutocompleteResponseChoice
8
- * @property {string} name The name of the choice
9
- * @property {string} value The value of the choice
10
- */
11
- /**
12
- * @typedef {object} AutocompleteResponse
13
- * @property {Snowflake} [nonce] Snowflake of the data
14
- * @property {Array<AutocompleteResponseChoice>} [choices] Array of choices
15
- */
16
- /**
17
- * Emitted when receiving a response from Discord
18
- * @event Client#applicationCommandAutocompleteResponse
19
- * @param {AutocompleteResponse} data Data
20
- * @deprecated Test only
21
- */
22
- client.emit(Events.APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, data);
23
- };
@@ -1,11 +0,0 @@
1
- 'use strict';
2
- const { Events } = require('../../../util/Constants');
3
-
4
- module.exports = (client, { d: data }) => {
5
- for (const command of data.application_commands) {
6
- const user = client.users.cache.get(command.application_id);
7
- if (!user || !user.bot) continue;
8
- user.application?.commands?._add(command, true);
9
- }
10
- client.emit(Events.GUILD_APPLICATION_COMMANDS_UPDATE, data);
11
- };
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- const { Collection } = require('@discordjs/collection');
4
- const { Events } = require('../../../util/Constants');
5
-
6
- module.exports = (client, { d: data }) => {
7
- const guild = client.guilds.cache.get(data.guild_id);
8
- if (!guild) return;
9
- const members = new Collection();
10
- // Get Member from side Discord Channel (online counting if large server)
11
- for (const object of data.ops) {
12
- switch (object.op) {
13
- case 'SYNC': {
14
- for (const member_ of object.items) {
15
- const member = member_.member;
16
- if (!member) continue;
17
- members.set(member.user.id, guild.members._add(member));
18
- if (member.presence) {
19
- guild.presences._add(Object.assign(member.presence, { guild }));
20
- }
21
- }
22
- break;
23
- }
24
- case 'INVALIDATE': {
25
- client.emit(
26
- Events.DEBUG,
27
- `Invalidate [${object.range[0]}, ${object.range[1]}], Fetching GuildId: ${data.guild_id}`,
28
- );
29
- break;
30
- }
31
- case 'UPDATE':
32
- case 'INSERT': {
33
- const member = object.item.member;
34
- if (!member) continue;
35
- members.set(member.user.id, guild.members._add(member));
36
- if (member.presence) {
37
- guild.presences._add(Object.assign(member.presence, { guild }));
38
- }
39
- break;
40
- }
41
- case 'DELETE': {
42
- break;
43
- }
44
- }
45
- }
46
- /**
47
- * Emitted whenever a guild member list (sidebar) is updated.
48
- * @event Client#guildMemberListUpdate
49
- * @param {Collection<Snowflake, GuildMember>} members Members that were updated
50
- * @param {Guild} guild Guild
51
- * @param {string} type Type of update (INVALIDATE | UPDATE | INSERT | DELETE | SYNC)
52
- * @param {data} raw Raw data
53
- */
54
- client.emit(Events.GUILD_MEMBER_LIST_UPDATE, members, guild, data.ops[0].op, data);
55
- };
@@ -1,16 +0,0 @@
1
- 'use strict';
2
- const { Events } = require('../../../util/Constants');
3
-
4
- /**
5
- * @typedef {Object} InteractionResponseBody
6
- * @property {Snowflake} id Interaction ID
7
- * @property {Snowflake} nonce nonce in POST /interactions
8
- */
9
-
10
- module.exports = (client, { d: data }) => {
11
- if (client.user.bot) {
12
- client.actions.InteractionCreate.handle(data);
13
- } else {
14
- client.emit(Events.INTERACTION_CREATE, data);
15
- }
16
- };
@@ -1,18 +0,0 @@
1
- 'use strict';
2
- const { Events } = require('../../../util/Constants');
3
-
4
- module.exports = (client, { d: data }) => {
5
- /**
6
- * Emitted whenever client user send interaction and error
7
- * @event Client#interactionFailure
8
- * @param {InteractionResponseBody} data data
9
- */
10
- client.emit(Events.INTERACTION_FAILURE, data);
11
- client.emit('interactionResponse', {
12
- status: false,
13
- metadata: client._interactionCache.get(data.nonce),
14
- error: 'No response from bot',
15
- });
16
- // Delete cache
17
- client._interactionCache.delete(data.nonce);
18
- };
@@ -1,30 +0,0 @@
1
- 'use strict';
2
- const { Events } = require('../../../util/Constants');
3
-
4
- module.exports = (client, { d: data }) => {
5
- /**
6
- * Emitted whenever client user send interaction and success
7
- * @event Client#interactionSuccess
8
- * @param {InteractionResponseBody} data data
9
- */
10
- client.emit(Events.INTERACTION_SUCCESS, data);
11
- // Get channel data
12
- const cache = client._interactionCache.get(data.nonce);
13
- if (!cache) return;
14
- const channel = cache.guildId
15
- ? client.guilds.cache.get(cache.guildId)?.channels.cache.get(cache.channelId)
16
- : client.channels.cache.get(cache.channelId);
17
- // Set data
18
- const interaction = {
19
- ...cache,
20
- ...data,
21
- };
22
- const data_ = channel.interactions._add(interaction);
23
- client.emit('interactionResponse', {
24
- status: true,
25
- metadata: data_,
26
- error: 'Success',
27
- });
28
- // Delete cache
29
- // client._interactionCache.delete(data.nonce);
30
- };
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- const { Events } = require('../../../util/Constants');
4
-
5
- module.exports = (client, { d: data }) => {
6
- const channel = client.channels.cache.get(data.channel_id);
7
- /**
8
- * Emitted whenever message is acknowledged (mark read / unread)
9
- * @event Client#messageAck
10
- * @param {TextChannel} channel Channel
11
- * @param {Snowflake} message_id Message ID
12
- * @param {boolean} isRead Whether the message is read
13
- * @param {Object} raw Raw data
14
- */
15
- client.emit(Events.MESSAGE_ACK, channel, data.message_id, !data.manual, data);
16
- };
@@ -1,104 +0,0 @@
1
- 'use strict';
2
-
3
- const { Collection } = require('@discordjs/collection');
4
- const BaseManager = require('./BaseManager');
5
- const DeveloperPortalApplication = require('../structures/DeveloperPortalApplication');
6
- const Team = require('../structures/Team');
7
-
8
- /**
9
- * Manages API methods for users and stores their cache.
10
- * @extends {BaseManager}
11
- */
12
- class DeveloperPortalManager extends BaseManager {
13
- constructor(client) {
14
- super(client);
15
- /**
16
- * A collection of all the applications the client has.
17
- * @type {Collection<Snowflake, DeveloperPortalApplication>}
18
- * @readonly
19
- */
20
- this.applications = new Collection();
21
- /**
22
- * A collection of all the teams the client has.
23
- * @type {Collection<Snowflake, Team>}
24
- * @readonly
25
- */
26
- this.teams = new Collection(); // Collection<Snowflake, Team>
27
- }
28
- /**
29
- * Fetches all the applications & teams the client has.
30
- * @returns {Promise<DeveloperPortalManager>}
31
- */
32
- async fetch() {
33
- const promise1 = this.client.api.applications.get({
34
- query: {
35
- with_team_applications: true,
36
- },
37
- });
38
- const promise2 = this.client.api.teams.get();
39
- const [applications, teams] = await Promise.all([promise1, promise2]);
40
- for (const team of teams) {
41
- this.teams.set(team.id, new Team(this.client, team));
42
- }
43
- for (const application of applications) {
44
- this.applications.set(application.id, new DeveloperPortalApplication(this.client, application));
45
- }
46
- return this;
47
- }
48
-
49
- /**
50
- * Creates a new Team.
51
- * @param {string} name Name of the team
52
- * @returns {Promise<Team>}
53
- */
54
- async createTeam(name) {
55
- const team = await this.client.api.teams.post({
56
- data: {
57
- name: name,
58
- },
59
- });
60
-
61
- this.teams.set(team.id, new Team(this.client, team));
62
- return this.teams.get(team.id);
63
- }
64
-
65
- /**
66
- * Creates a new application.
67
- * @param {string} name Name of the application
68
- * @param {?Snowflake | Team} teamId The team to create the application in
69
- * @returns {Promise<DeveloperPortalApplication>}
70
- */
71
- async createApplication(name, teamId = null) {
72
- teamId = teamId instanceof Team ? teamId.id : teamId;
73
- const application = await this.client.api.applications.post({
74
- data: {
75
- name,
76
- team_id: teamId,
77
- },
78
- });
79
- this.applications.set(application.id, new DeveloperPortalApplication(this.client, application));
80
- return this.applications.get(application.id);
81
- }
82
-
83
- /**
84
- * Deletes an application.
85
- * @param {Snowflake} id Application ID
86
- * @param {?number} MFACode 2FA code (if 2FA is enabled)
87
- * @returns {Promise<void>}
88
- */
89
- async deleteApplication(id, MFACode) {
90
- if (MFACode) {
91
- await this.client.api.applications[`${id}/delete`].post({
92
- query: {
93
- code: MFACode,
94
- },
95
- });
96
- } else {
97
- await this.client.api.applications[`${id}/delete`].post();
98
- }
99
- this.applications.delete(id);
100
- return undefined;
101
- }
102
- }
103
-
104
- module.exports = DeveloperPortalManager;
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- const ApplicationCommandManager = require('./ApplicationCommandManager');
4
- const ApplicationCommandPermissionsManager = require('./ApplicationCommandPermissionsManager');
5
-
6
- /**
7
- * An extension for guild-specific application commands.
8
- * @extends {ApplicationCommandManager}
9
- */
10
- class GuildApplicationCommandManager extends ApplicationCommandManager {
11
- constructor(guild, iterable) {
12
- super(guild.client, iterable);
13
-
14
- /**
15
- * The guild that this manager belongs to
16
- * @type {Guild}
17
- */
18
- this.guild = guild;
19
-
20
- /**
21
- * The manager for permissions of arbitrary commands on this guild
22
- * @type {ApplicationCommandPermissionsManager}
23
- */
24
- this.permissions = new ApplicationCommandPermissionsManager(this);
25
- }
26
- }
27
-
28
- module.exports = GuildApplicationCommandManager;
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- const { Collection } = require('@discordjs/collection');
4
- const BaseManager = require('./BaseManager');
5
-
6
- /**
7
- * Manages API methods for users and stores their cache.
8
- * @extends {BaseManager}
9
- */
10
- class GuildFolderManager extends BaseManager {
11
- constructor(client) {
12
- super(client);
13
- /**
14
- * The guild folder cache (Index, GuildFolder)
15
- * @type {Collection<number, GuildFolder>}
16
- */
17
- this.cache = new Collection();
18
- }
19
- _refresh() {
20
- this.cache.clear();
21
- }
22
- }
23
-
24
- module.exports = GuildFolderManager;
@@ -1,57 +0,0 @@
1
- 'use strict';
2
-
3
- const CachedManager = require('./CachedManager');
4
- const { Error } = require('../errors/DJSError');
5
- const Session = require('../structures/Session');
6
- /**
7
- * Manages API methods for users and stores their cache.
8
- * @extends {CachedManager}
9
- */
10
- class SessionManager extends CachedManager {
11
- constructor(client, iterable) {
12
- super(client, Session, iterable);
13
- }
14
- /**
15
- * The cache of Sessions
16
- * @type {Collection<string, Session>}
17
- * @name SessionManager#cache
18
- */
19
-
20
- /**
21
- * Fetch all sessions of the client.
22
- * @returns {Promise<SessionManager>}
23
- */
24
- fetch() {
25
- return new Promise((resolve, reject) => {
26
- this.client.api.auth.sessions
27
- .get()
28
- .then(data => {
29
- const allData = data.user_sessions;
30
- this.cache.clear();
31
- for (const session of allData) {
32
- this._add(new Session(this.client, session), true, { id: session.id_hash });
33
- }
34
- resolve(this);
35
- })
36
- .catch(reject);
37
- });
38
- }
39
-
40
- /**
41
- * Logout the client (remote).
42
- * @param {string | null} mfaCode MFA code (if 2FA is enabled)
43
- * @returns {Promise<undefined>}
44
- */
45
- logoutAllDevices(mfaCode) {
46
- if (typeof this.client.password !== 'string') throw new Error('REQUIRE_PASSWORD');
47
- return this.client.api.auth.sessions.logout({
48
- data: {
49
- session_id_hashes: this.cache.map(session => session.id),
50
- password: this.client.password,
51
- code: typeof mfaCode === 'string' ? mfaCode : undefined,
52
- },
53
- });
54
- }
55
- }
56
-
57
- module.exports = SessionManager;
@@ -1,132 +0,0 @@
1
- 'use strict';
2
-
3
- const proxyParser = proxy => {
4
- const protocolSplit = proxy.split('://');
5
- const protocol = protocolSplit.length === 1 ? null : protocolSplit[0];
6
- const rest = protocolSplit.length === 1 ? protocolSplit[0] : protocolSplit[1];
7
- const authSplit = rest.split('@');
8
- if (authSplit.length === 1) {
9
- const host = authSplit[0].split(':')[0];
10
- const port = Number(authSplit[0].split(':')[1]);
11
- const proxyConfig = {
12
- host,
13
- port,
14
- };
15
- if (protocol != null) {
16
- proxyConfig.protocol = protocol;
17
- }
18
- return proxyConfig;
19
- }
20
- const host = authSplit[1].split(':')[0];
21
- const port = Number(authSplit[1].split(':')[1]);
22
- const [username, password] = authSplit[0].split(':');
23
- const proxyConfig = {
24
- host,
25
- port,
26
- auth: {
27
- username,
28
- password,
29
- },
30
- };
31
- if (protocol != null) {
32
- proxyConfig.protocol = protocol;
33
- }
34
- return proxyConfig;
35
- };
36
-
37
- module.exports = class CaptchaSolver {
38
- constructor(service, key, defaultCaptchaSolver, proxyString = '') {
39
- this.service = 'custom';
40
- this.solver = undefined;
41
- this.defaultCaptchaSolver = defaultCaptchaSolver;
42
- this.key = null;
43
- this.proxy = proxyString.length ? proxyParser(proxyString) : null;
44
- this._setup(service, key);
45
- }
46
- _missingModule(name) {
47
- return new Error(`${name} module not found, please install it with \`npm i ${name}\``);
48
- }
49
- _setup(service, key) {
50
- switch (service) {
51
- case '2captcha': {
52
- if (!key || typeof key !== 'string') throw new Error('2captcha key is not provided');
53
- try {
54
- const lib = require('2captcha');
55
- this.service = '2captcha';
56
- this.key = key;
57
- this.solver = new lib.Solver(key);
58
- this.solve = (data, userAgent) =>
59
- new Promise((resolve, reject) => {
60
- const siteKey = data.captcha_sitekey;
61
- let postD = {};
62
- if (this.proxy !== null) {
63
- postD = {
64
- proxytype: this.proxy.protocol?.toUpperCase(),
65
- proxy: `${'auth' in this.proxy ? `${this.proxy.auth.username}:${this.proxy.auth.password}@` : ''}${
66
- this.proxy.host
67
- }:${this.proxy.port}`,
68
- };
69
- }
70
- if (data.captcha_rqdata) {
71
- postD = {
72
- ...postD,
73
- data: data.captcha_rqdata,
74
- userAgent,
75
- };
76
- }
77
- this.solver
78
- .hcaptcha(siteKey, 'https://discord.com/channels/@me', postD)
79
- .then(res => {
80
- resolve(res.data);
81
- })
82
- .catch(reject);
83
- });
84
- break;
85
- } catch (e) {
86
- throw this._missingModule('2captcha');
87
- }
88
- }
89
- case 'capmonster': {
90
- if (!key || typeof key !== 'string') throw new Error('Capmonster key is not provided');
91
- try {
92
- const { HCaptchaTask } = require('node-capmonster');
93
- this.service = 'capmonster';
94
- this.key = key;
95
- const client = new HCaptchaTask(this.key);
96
- this.solve = (captchaData, userAgent) =>
97
- new Promise((resolve, reject) => {
98
- if (userAgent) client.setUserAgent(userAgent);
99
- if (this.proxy !== null) {
100
- client.setProxy(
101
- this.proxy.protocol,
102
- this.proxy.host,
103
- this.proxy.port,
104
- 'auth' in this.proxy ? this.proxy.auth.username : undefined,
105
- 'auth' in this.proxy ? this.proxy.auth.password : undefined,
106
- );
107
- }
108
- client
109
- .createWithTask(
110
- client.task({
111
- websiteURL: 'https://discord.com/channels/@me',
112
- websiteKey: captchaData.captcha_sitekey,
113
- isInvisible: !!captchaData.captcha_rqdata,
114
- data: captchaData.captcha_rqdata,
115
- }),
116
- )
117
- .then(id => client.joinTaskResult(id))
118
- .then(result => resolve(result.gRecaptchaResponse))
119
- .catch(reject);
120
- });
121
- } catch (e) {
122
- throw this._missingModule('node-capmonster');
123
- }
124
- break;
125
- }
126
- default: {
127
- this.solve = this.defaultCaptchaSolver;
128
- }
129
- }
130
- }
131
- solve() {}
132
- };