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.
- package/README.md +31 -16
- package/package.json +15 -8
- package/src/client/BaseClient.js +3 -2
- package/src/client/Client.js +539 -187
- package/src/client/actions/Action.js +13 -18
- package/src/client/actions/ActionsManager.js +1 -7
- package/src/client/actions/AutoModerationActionExecution.js +0 -1
- package/src/client/actions/AutoModerationRuleCreate.js +0 -1
- package/src/client/actions/AutoModerationRuleDelete.js +0 -1
- package/src/client/actions/AutoModerationRuleUpdate.js +0 -1
- package/src/client/actions/InteractionCreate.js +115 -0
- package/src/client/actions/MessageCreate.js +4 -0
- package/src/client/actions/PresenceUpdate.js +16 -17
- package/src/client/websocket/WebSocketManager.js +31 -11
- package/src/client/websocket/WebSocketShard.js +38 -39
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +23 -0
- 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 +13 -16
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +11 -0
- package/src/client/websocket/handlers/GUILD_CREATE.js +0 -7
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +55 -0
- 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 +16 -0
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +18 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +0 -1
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +30 -0
- package/src/client/websocket/handlers/MESSAGE_ACK.js +16 -0
- package/src/client/websocket/handlers/READY.js +137 -47
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +5 -7
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +4 -6
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +9 -32
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +8 -2
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +5 -1
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
- package/src/client/websocket/handlers/index.js +20 -15
- package/src/errors/Messages.js +69 -24
- package/src/index.js +43 -12
- package/src/managers/ApplicationCommandManager.js +12 -9
- package/src/managers/ApplicationCommandPermissionsManager.js +11 -3
- package/src/managers/ChannelManager.js +4 -2
- package/src/managers/ClientUserSettingManager.js +279 -161
- package/src/managers/DeveloperPortalManager.js +104 -0
- package/src/managers/GuildApplicationCommandManager.js +28 -0
- package/src/managers/GuildBanManager.js +1 -1
- package/src/managers/GuildChannelManager.js +0 -2
- package/src/managers/GuildFolderManager.js +24 -0
- package/src/managers/GuildForumThreadManager.js +28 -22
- package/src/managers/GuildMemberManager.js +216 -40
- package/src/managers/GuildSettingManager.js +15 -22
- package/src/managers/MessageManager.js +44 -42
- package/src/managers/PermissionOverwriteManager.js +1 -1
- package/src/managers/ReactionUserManager.js +5 -5
- package/src/managers/RelationshipManager.js +74 -81
- package/src/managers/SessionManager.js +57 -0
- package/src/managers/ThreadManager.js +45 -12
- package/src/managers/ThreadMemberManager.js +1 -1
- package/src/managers/UserManager.js +10 -6
- package/src/rest/APIRequest.js +20 -42
- package/src/rest/CaptchaSolver.js +132 -0
- package/src/rest/DiscordAPIError.js +16 -17
- package/src/rest/RESTManager.js +21 -1
- package/src/rest/RequestHandler.js +21 -35
- package/src/structures/ApplicationCommand.js +456 -19
- package/src/structures/ApplicationRoleConnectionMetadata.js +0 -3
- package/src/structures/AutoModerationRule.js +5 -5
- package/src/structures/AutocompleteInteraction.js +0 -1
- package/src/structures/BaseGuildTextChannel.js +12 -10
- package/src/structures/BaseGuildVoiceChannel.js +18 -16
- package/src/structures/{CallState.js → Call.js} +12 -17
- package/src/structures/CategoryChannel.js +0 -2
- package/src/structures/Channel.js +3 -2
- package/src/structures/ClientApplication.js +204 -0
- package/src/structures/ClientPresence.js +8 -12
- package/src/structures/ClientUser.js +336 -117
- package/src/structures/ContextMenuInteraction.js +1 -1
- package/src/structures/DMChannel.js +92 -29
- package/src/structures/DeveloperPortalApplication.js +520 -0
- package/src/structures/ForumChannel.js +10 -0
- package/src/structures/Guild.js +271 -135
- package/src/structures/GuildAuditLogs.js +5 -0
- package/src/structures/GuildChannel.js +2 -16
- package/src/structures/GuildFolder.js +75 -0
- package/src/structures/GuildMember.js +145 -27
- package/src/structures/Interaction.js +62 -1
- package/src/structures/InteractionResponse.js +114 -0
- package/src/structures/Invite.js +52 -35
- package/src/structures/Message.js +202 -222
- package/src/structures/MessageAttachment.js +0 -11
- package/src/structures/MessageButton.js +67 -1
- package/src/structures/MessageEmbed.js +1 -1
- package/src/structures/MessageMentions.js +2 -3
- package/src/structures/MessagePayload.js +46 -4
- package/src/structures/MessageReaction.js +1 -1
- package/src/structures/MessageSelectMenu.js +252 -1
- package/src/structures/Modal.js +180 -75
- package/src/structures/PartialGroupDMChannel.js +433 -0
- package/src/structures/Presence.js +2 -2
- package/src/structures/RichPresence.js +34 -14
- package/src/structures/Role.js +2 -18
- package/src/structures/SelectMenuInteraction.js +151 -2
- package/src/structures/Session.js +81 -0
- package/src/structures/Team.js +49 -0
- package/src/structures/TextInputComponent.js +70 -0
- package/src/structures/ThreadChannel.js +19 -0
- package/src/structures/User.js +345 -117
- package/src/structures/UserContextMenuInteraction.js +2 -2
- package/src/structures/VoiceState.js +39 -74
- package/src/structures/WebEmbed.js +52 -38
- package/src/structures/Webhook.js +11 -17
- package/src/structures/interfaces/Application.js +23 -146
- package/src/structures/interfaces/TextBasedChannel.js +256 -411
- package/src/util/ApplicationFlags.js +1 -1
- package/src/util/Constants.js +284 -106
- package/src/util/Formatters.js +2 -16
- package/src/util/LimitedCollection.js +1 -1
- package/src/util/Options.js +68 -48
- package/src/util/Permissions.js +0 -5
- package/src/util/PurchasedFlags.js +0 -2
- package/src/util/RemoteAuth.js +356 -221
- package/src/util/Sweepers.js +1 -1
- package/src/util/Util.js +36 -76
- package/src/util/Voice.js +1456 -0
- package/src/util/arRPC/index.js +229 -0
- package/src/util/arRPC/process/detectable.json +1 -0
- package/src/util/arRPC/process/index.js +102 -0
- package/src/util/arRPC/process/native/index.js +5 -0
- package/src/util/arRPC/process/native/linux.js +37 -0
- package/src/util/arRPC/process/native/win32.js +25 -0
- package/src/util/arRPC/transports/ipc.js +281 -0
- package/src/util/arRPC/transports/websocket.js +128 -0
- package/typings/enums.d.ts +73 -18
- package/typings/index.d.ts +1249 -897
- package/typings/rawDataTypes.d.ts +9 -68
- package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +0 -78
- package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +0 -12
- package/src/managers/UserNoteManager.js +0 -53
- package/src/structures/GroupDMChannel.js +0 -387
- package/src/util/AttachmentFlags.js +0 -38
- package/src/util/InviteFlags.js +0 -29
- package/src/util/RoleFlags.js +0 -37
package/src/errors/Messages.js
CHANGED
|
@@ -11,6 +11,8 @@ const Messages = {
|
|
|
11
11
|
TOKEN_INVALID: 'An invalid token was provided.',
|
|
12
12
|
TOKEN_MISSING: 'Request to use token, but token was unavailable to the client.',
|
|
13
13
|
|
|
14
|
+
MFA_INVALID: 'An invalid mfa code was provided',
|
|
15
|
+
|
|
14
16
|
WS_CLOSE_REQUESTED: 'WebSocket closed due to user request.',
|
|
15
17
|
WS_CONNECTION_EXISTS: 'There is already an existing WebSocket connection.',
|
|
16
18
|
WS_NOT_OPEN: (data = 'data') => `WebSocket not open to send ${data}`,
|
|
@@ -18,8 +20,8 @@ const Messages = {
|
|
|
18
20
|
|
|
19
21
|
BITFIELD_INVALID: bit => `Invalid bitfield flag or number: ${bit}.`,
|
|
20
22
|
|
|
21
|
-
SHARDING_INVALID: '
|
|
22
|
-
SHARDING_REQUIRED: '
|
|
23
|
+
SHARDING_INVALID: 'Invalid shard settings were provided.',
|
|
24
|
+
SHARDING_REQUIRED: 'This session would have handled too many guilds - Sharding is required.',
|
|
23
25
|
INVALID_INTENTS: '[Bot Token] Invalid intent provided for WebSocket intents.',
|
|
24
26
|
DISALLOWED_INTENTS: '[Bot Token] Privileged intent provided is not enabled or whitelisted.',
|
|
25
27
|
SHARDING_NO_SHARDS: 'No shards have been spawned.',
|
|
@@ -47,6 +49,12 @@ const Messages = {
|
|
|
47
49
|
EMBED_FOOTER_TEXT: 'MessageEmbed footer text must be a string.',
|
|
48
50
|
EMBED_DESCRIPTION: 'MessageEmbed description must be a string.',
|
|
49
51
|
EMBED_AUTHOR_NAME: 'MessageEmbed author name must be a string.',
|
|
52
|
+
/* Add */
|
|
53
|
+
MISSING_PERMISSIONS: (...permission) => `You can't do this action [Missing Permission(s): ${permission.join(', ')}]`,
|
|
54
|
+
EMBED_PROVIDER_NAME: 'MessageEmbed provider name must be a string.',
|
|
55
|
+
INVALID_COMMAND_NAME: allCMD => `Could not parse subGroupCommand and subCommand due to too long: ${allCMD.join(' ')}`,
|
|
56
|
+
INVALID_RANGE_QUERY_MEMBER: 'Invalid range query member. (0<x<=100)',
|
|
57
|
+
MUST_SPECIFY_BOT: 'You must specify a bot to use this command.',
|
|
50
58
|
|
|
51
59
|
BUTTON_LABEL: 'MessageButton label must be a string',
|
|
52
60
|
BUTTON_URL: 'MessageButton URL must be a string',
|
|
@@ -58,20 +66,13 @@ const Messages = {
|
|
|
58
66
|
SELECT_OPTION_VALUE: 'MessageSelectOption value must be a string',
|
|
59
67
|
SELECT_OPTION_DESCRIPTION: 'MessageSelectOption description must be a string',
|
|
60
68
|
|
|
61
|
-
TEXT_INPUT_CUSTOM_ID: 'TextInputComponent customId must be a string',
|
|
62
|
-
TEXT_INPUT_LABEL: 'TextInputComponent label must be a string',
|
|
63
|
-
TEXT_INPUT_PLACEHOLDER: 'TextInputComponent placeholder must be a string',
|
|
64
|
-
TEXT_INPUT_VALUE: 'TextInputComponent value must be a string',
|
|
65
|
-
|
|
66
|
-
MODAL_CUSTOM_ID: 'Modal customId must be a string',
|
|
67
|
-
MODAL_TITLE: 'Modal title must be a string',
|
|
68
|
-
|
|
69
69
|
INTERACTION_COLLECTOR_ERROR: reason => `Collector received no interactions before ending with reason: ${reason}`,
|
|
70
70
|
|
|
71
71
|
FILE_NOT_FOUND: file => `File could not be found: ${file}`,
|
|
72
72
|
|
|
73
73
|
USER_BANNER_NOT_FETCHED: "You must fetch this user's banner before trying to generate its URL!",
|
|
74
74
|
USER_NO_DM_CHANNEL: 'No DM Channel exists!',
|
|
75
|
+
CLIENT_NO_CALL: 'No call exists!',
|
|
75
76
|
|
|
76
77
|
VOICE_NOT_STAGE_CHANNEL: 'You are only allowed to do this in stage channels.',
|
|
77
78
|
|
|
@@ -101,11 +102,17 @@ const Messages = {
|
|
|
101
102
|
GUILD_CHANNEL_UNOWNED: "The fetched channel does not belong to this manager's guild.",
|
|
102
103
|
GUILD_OWNED: 'Guild is owned by the client.',
|
|
103
104
|
GUILD_MEMBERS_TIMEOUT: "Members didn't arrive in time.",
|
|
105
|
+
GUILD_APPLICATION_COMMANDS_SEARCH_TIMEOUT: "Application commands didn't arrive in time.",
|
|
104
106
|
GUILD_UNCACHED_ME: 'The client user as a member of this guild is uncached.',
|
|
105
107
|
CHANNEL_NOT_CACHED: 'Could not find the channel where this message came from in the cache!',
|
|
106
108
|
STAGE_CHANNEL_RESOLVE: 'Could not resolve channel to a stage channel.',
|
|
107
109
|
GUILD_SCHEDULED_EVENT_RESOLVE: 'Could not resolve the guild scheduled event.',
|
|
108
110
|
|
|
111
|
+
REQUIRE_PASSWORD: 'You must provide a password.',
|
|
112
|
+
INVALIDATE_MEMBER: range => `Invalid member range: [${range[0]}, ${range[1]}]`,
|
|
113
|
+
|
|
114
|
+
MISSING_VALUE: (where, type) => `Missing value for ${where} (${type})`,
|
|
115
|
+
|
|
109
116
|
INVALID_TYPE: (name, expected, an = false) => `Supplied ${name} is not a${an ? 'n' : ''} ${expected}.`,
|
|
110
117
|
INVALID_ELEMENT: (type, name, elem) => `Supplied ${type} ${name} includes an invalid element: ${elem}`,
|
|
111
118
|
|
|
@@ -133,6 +140,10 @@ const Messages = {
|
|
|
133
140
|
|
|
134
141
|
INVITE_NOT_FOUND: 'Could not find the requested invite.',
|
|
135
142
|
|
|
143
|
+
NOT_OWNER_GROUP_DM_CHANNEL: "You can't do this action [Missing Permission]",
|
|
144
|
+
USER_ALREADY_IN_GROUP_DM_CHANNEL: 'User is already in the channel.',
|
|
145
|
+
USER_NOT_IN_GROUP_DM_CHANNEL: 'User is not in the channel.',
|
|
146
|
+
|
|
136
147
|
DELETE_GROUP_DM_CHANNEL: "Bots don't have access to Group DM Channels and cannot delete them",
|
|
137
148
|
FETCH_GROUP_DM_CHANNEL: "Bots don't have access to Group DM Channels and cannot fetch them",
|
|
138
149
|
|
|
@@ -145,6 +156,8 @@ const Messages = {
|
|
|
145
156
|
|
|
146
157
|
INTERACTION_ALREADY_REPLIED: 'The reply to this interaction has already been sent or deferred.',
|
|
147
158
|
INTERACTION_NOT_REPLIED: 'The reply to this interaction has not been sent or deferred.',
|
|
159
|
+
/** @deprecated */
|
|
160
|
+
INTERACTION_EPHEMERAL_REPLIED: 'Ephemeral responses cannot be deleted.',
|
|
148
161
|
|
|
149
162
|
COMMAND_INTERACTION_OPTION_NOT_FOUND: name => `Required option "${name}" not found.`,
|
|
150
163
|
COMMAND_INTERACTION_OPTION_TYPE: (name, type, expected) =>
|
|
@@ -155,28 +168,60 @@ const Messages = {
|
|
|
155
168
|
COMMAND_INTERACTION_OPTION_NO_SUB_COMMAND_GROUP: 'No subcommand group specified for interaction.',
|
|
156
169
|
AUTOCOMPLETE_INTERACTION_OPTION_NO_FOCUSED_OPTION: 'No focused option for autocomplete interaction.',
|
|
157
170
|
|
|
158
|
-
MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND: customId => `Required field with custom id "${customId}" not found.`,
|
|
159
|
-
MODAL_SUBMIT_INTERACTION_FIELD_TYPE: (customId, type, expected) =>
|
|
160
|
-
`Field with custom id "${customId}" is of type: ${type}; expected ${expected}.`,
|
|
161
|
-
|
|
162
171
|
INVITE_MISSING_SCOPES: 'At least one valid scope must be provided for the invite',
|
|
163
172
|
|
|
164
173
|
NOT_IMPLEMENTED: (what, name) => `Method ${what} not implemented on ${name}.`,
|
|
165
174
|
|
|
166
175
|
SWEEP_FILTER_RETURN: 'The return value of the sweepFilter function was not false or a Function',
|
|
167
176
|
|
|
177
|
+
INVALID_BOT_METHOD: 'Bot accounts cannot use this method',
|
|
178
|
+
INVALID_USER_METHOD: 'User accounts cannot use this method',
|
|
179
|
+
BOT_ONLY: 'This method only for bots',
|
|
180
|
+
USER_ONLY: 'This method only for users',
|
|
181
|
+
|
|
182
|
+
INTERACTION_SEND_FAILURE: msg => `${msg}`,
|
|
183
|
+
|
|
184
|
+
INVALID_LOCALE: 'Unable to select this location',
|
|
185
|
+
FOLDER_NOT_FOUND: 'Server directory not found',
|
|
186
|
+
FOLDER_POSITION_INVALID: 'The server index in the directory is invalid',
|
|
187
|
+
APPLICATION_ID_INVALID: "The application isn't BOT",
|
|
188
|
+
INVALID_NITRO: 'Invalid Nitro Code',
|
|
189
|
+
MESSAGE_ID_NOT_FOUND: 'Message ID not found',
|
|
190
|
+
MESSAGE_EMBED_LINK_LENGTH: 'Message content with embed link length is too long',
|
|
191
|
+
GUILD_MEMBERS_FETCH: msg => `${msg}`,
|
|
192
|
+
USER_NOT_STREAMING: 'User is not streaming',
|
|
193
|
+
// Djs v13.7
|
|
194
|
+
TEXT_INPUT_CUSTOM_ID: 'TextInputComponent customId must be a string',
|
|
195
|
+
TEXT_INPUT_LABEL: 'TextInputComponent label must be a string',
|
|
196
|
+
TEXT_INPUT_PLACEHOLDER: 'TextInputComponent placeholder must be a string',
|
|
197
|
+
TEXT_INPUT_VALUE: 'TextInputComponent value must be a string',
|
|
198
|
+
|
|
199
|
+
MODAL_CUSTOM_ID: 'Modal customId must be a string',
|
|
200
|
+
MODAL_TITLE: 'Modal title must be a string',
|
|
201
|
+
|
|
202
|
+
MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND: customId => `Required field with custom id "${customId}" not found.`,
|
|
203
|
+
MODAL_SUBMIT_INTERACTION_FIELD_TYPE: (customId, type, expected) =>
|
|
204
|
+
`Field with custom id "${customId}" is of type: ${type}; expected ${expected}.`,
|
|
205
|
+
|
|
206
|
+
INVALID_REMOTE_AUTH_URL: 'Invalid remote auth URL (https://discord.com/ra/{hash})',
|
|
207
|
+
INVALID_URL: url =>
|
|
208
|
+
`Invalid URL: ${url}.\nMake sure you are using a valid URL (https://discord.com/oauth2/authorize?...)`,
|
|
209
|
+
|
|
210
|
+
NITRO_REQUIRED: 'This feature is only available for Nitro users.',
|
|
211
|
+
NITRO_BOOST_REQUIRED: feature => `This feature (${feature}) is only available for Nitro Boost users.`,
|
|
212
|
+
ONLY_ME: 'This feature is only available for self.',
|
|
213
|
+
MISSING_CAPTCHA_SERVICE: 'This feature is only available for enabled captcha handler.',
|
|
214
|
+
|
|
168
215
|
GUILD_FORUM_MESSAGE_REQUIRED: 'You must provide a message to create a guild forum thread',
|
|
216
|
+
NORMAL_LOGIN: 'Username and password are required for normal login',
|
|
217
|
+
LOGIN_FAILED_UNKNOWN: 'Login failed',
|
|
218
|
+
LOGIN_FAILED_2FA: 'Login failed, 2FA code is required',
|
|
219
|
+
GUILD_IS_LARGE: 'This guild is too large to fetch all members with this method',
|
|
169
220
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
`${value} is not a valid choice for this option (${parentOptions})`,
|
|
175
|
-
SLASH_COMMAND_REQUIRED_OPTIONS_MISSING: (req, opt) => `Value required (${req}) missing (Options: ${opt})`,
|
|
176
|
-
SLASH_COMMAND_SUB_COMMAND_GROUP_INVALID: n => `${n} is not a valid sub command group`,
|
|
177
|
-
SLASH_COMMAND_SUB_COMMAND_INVALID: n => `${n} is not a valid sub command`,
|
|
178
|
-
INTERACTION_FAILED: 'No responsed from Application Command',
|
|
179
|
-
USER_NOT_STREAMING: 'User is not streaming',
|
|
221
|
+
TEAM_MEMBER_FORMAT: 'The member provided is either not real or not of the User class',
|
|
222
|
+
|
|
223
|
+
MISSING_MODULE: (name, installCommand) =>
|
|
224
|
+
`The module "${name}" is missing. Please install it with "${installCommand}" and try again.`,
|
|
180
225
|
};
|
|
181
226
|
|
|
182
227
|
for (const [name, message] of Object.entries(Messages)) register(name, message);
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const tls = require('tls');
|
|
4
|
+
// Cipher
|
|
5
|
+
tls.DEFAULT_CIPHERS = tls.DEFAULT_CIPHERS.split(':')
|
|
6
|
+
.sort(() => Math.random() - 0.5)
|
|
7
|
+
.join(':');
|
|
8
|
+
|
|
3
9
|
// "Root" classes (starting points)
|
|
4
10
|
exports.BaseClient = require('./client/BaseClient');
|
|
5
11
|
exports.Client = require('./client/Client');
|
|
@@ -9,9 +15,9 @@ exports.ShardingManager = require('./sharding/ShardingManager');
|
|
|
9
15
|
exports.WebhookClient = require('./client/WebhookClient');
|
|
10
16
|
|
|
11
17
|
// Utilities
|
|
18
|
+
exports.DiscordRPCServer = require('./util/arRPC/index');
|
|
12
19
|
exports.ActivityFlags = require('./util/ActivityFlags');
|
|
13
20
|
exports.ApplicationFlags = require('./util/ApplicationFlags');
|
|
14
|
-
exports.AttachmentFlags = require('./util/AttachmentFlags');
|
|
15
21
|
exports.BaseManager = require('./managers/BaseManager');
|
|
16
22
|
exports.BitField = require('./util/BitField');
|
|
17
23
|
exports.Collection = require('@discordjs/collection').Collection;
|
|
@@ -27,7 +33,6 @@ exports.MessageFlags = require('./util/MessageFlags');
|
|
|
27
33
|
exports.Options = require('./util/Options');
|
|
28
34
|
exports.Permissions = require('./util/Permissions');
|
|
29
35
|
exports.RateLimitError = require('./rest/RateLimitError');
|
|
30
|
-
exports.RoleFlags = require('./util/RoleFlags');
|
|
31
36
|
exports.SnowflakeUtil = require('./util/SnowflakeUtil');
|
|
32
37
|
exports.Sweepers = require('./util/Sweepers');
|
|
33
38
|
exports.SystemChannelFlags = require('./util/SystemChannelFlags');
|
|
@@ -35,6 +40,8 @@ exports.ThreadMemberFlags = require('./util/ThreadMemberFlags');
|
|
|
35
40
|
exports.UserFlags = require('./util/UserFlags');
|
|
36
41
|
exports.Util = require('./util/Util');
|
|
37
42
|
exports.version = require('../package.json').version;
|
|
43
|
+
exports.DiscordAuthWebsocket = require('./util/RemoteAuth');
|
|
44
|
+
exports.PurchasedFlags = require('./util/PurchasedFlags');
|
|
38
45
|
|
|
39
46
|
// Managers
|
|
40
47
|
exports.ApplicationCommandManager = require('./managers/ApplicationCommandManager');
|
|
@@ -45,6 +52,7 @@ exports.CachedManager = require('./managers/CachedManager');
|
|
|
45
52
|
exports.ChannelManager = require('./managers/ChannelManager');
|
|
46
53
|
exports.ClientVoiceManager = require('./client/voice/ClientVoiceManager');
|
|
47
54
|
exports.DataManager = require('./managers/DataManager');
|
|
55
|
+
exports.GuildApplicationCommandManager = require('./managers/GuildApplicationCommandManager');
|
|
48
56
|
exports.GuildBanManager = require('./managers/GuildBanManager');
|
|
49
57
|
exports.GuildChannelManager = require('./managers/GuildChannelManager');
|
|
50
58
|
exports.GuildEmojiManager = require('./managers/GuildEmojiManager');
|
|
@@ -61,6 +69,7 @@ exports.PresenceManager = require('./managers/PresenceManager');
|
|
|
61
69
|
exports.ReactionManager = require('./managers/ReactionManager');
|
|
62
70
|
exports.ReactionUserManager = require('./managers/ReactionUserManager');
|
|
63
71
|
exports.RoleManager = require('./managers/RoleManager');
|
|
72
|
+
exports.SessionManager = require('./managers/SessionManager');
|
|
64
73
|
exports.StageInstanceManager = require('./managers/StageInstanceManager');
|
|
65
74
|
exports.ThreadManager = require('./managers/ThreadManager');
|
|
66
75
|
exports.ThreadMemberManager = require('./managers/ThreadMemberManager');
|
|
@@ -69,7 +78,6 @@ exports.VoiceStateManager = require('./managers/VoiceStateManager');
|
|
|
69
78
|
exports.WebSocketManager = require('./client/websocket/WebSocketManager');
|
|
70
79
|
exports.WebSocketShard = require('./client/websocket/WebSocketShard');
|
|
71
80
|
exports.RelationshipManager = require('./managers/RelationshipManager');
|
|
72
|
-
exports.UserNoteManager = require('./managers/UserNoteManager');
|
|
73
81
|
|
|
74
82
|
// Structures
|
|
75
83
|
exports.Activity = require('./structures/Presence').Activity;
|
|
@@ -78,18 +86,26 @@ exports.Application = require('./structures/interfaces/Application');
|
|
|
78
86
|
exports.ApplicationCommand = require('./structures/ApplicationCommand');
|
|
79
87
|
exports.ApplicationRoleConnectionMetadata =
|
|
80
88
|
require('./structures/ApplicationRoleConnectionMetadata').ApplicationRoleConnectionMetadata;
|
|
89
|
+
exports.AutocompleteInteraction = require('./structures/AutocompleteInteraction');
|
|
81
90
|
exports.AutoModerationActionExecution = require('./structures/AutoModerationActionExecution');
|
|
82
91
|
exports.AutoModerationRule = require('./structures/AutoModerationRule');
|
|
83
92
|
exports.Base = require('./structures/Base');
|
|
93
|
+
exports.BaseCommandInteraction = require('./structures/BaseCommandInteraction');
|
|
84
94
|
exports.BaseGuild = require('./structures/BaseGuild');
|
|
85
95
|
exports.BaseGuildEmoji = require('./structures/BaseGuildEmoji');
|
|
86
96
|
exports.BaseGuildTextChannel = require('./structures/BaseGuildTextChannel');
|
|
87
97
|
exports.BaseGuildVoiceChannel = require('./structures/BaseGuildVoiceChannel');
|
|
98
|
+
exports.BaseMessageComponent = require('./structures/BaseMessageComponent');
|
|
99
|
+
exports.ButtonInteraction = require('./structures/ButtonInteraction');
|
|
88
100
|
exports.CategoryChannel = require('./structures/CategoryChannel');
|
|
89
101
|
exports.Channel = require('./structures/Channel').Channel;
|
|
102
|
+
exports.ClientApplication = require('./structures/ClientApplication');
|
|
90
103
|
exports.ClientPresence = require('./structures/ClientPresence');
|
|
91
104
|
exports.ClientUser = require('./structures/ClientUser');
|
|
92
105
|
exports.Collector = require('./structures/interfaces/Collector');
|
|
106
|
+
exports.CommandInteraction = require('./structures/CommandInteraction');
|
|
107
|
+
exports.CommandInteractionOptionResolver = require('./structures/CommandInteractionOptionResolver');
|
|
108
|
+
exports.ContextMenuInteraction = require('./structures/ContextMenuInteraction');
|
|
93
109
|
exports.DMChannel = require('./structures/DMChannel');
|
|
94
110
|
exports.Emoji = require('./structures/Emoji').Emoji;
|
|
95
111
|
exports.Guild = require('./structures/Guild').Guild;
|
|
@@ -105,27 +121,49 @@ exports.GuildScheduledEvent = require('./structures/GuildScheduledEvent').GuildS
|
|
|
105
121
|
exports.GuildTemplate = require('./structures/GuildTemplate');
|
|
106
122
|
exports.Integration = require('./structures/Integration');
|
|
107
123
|
exports.IntegrationApplication = require('./structures/IntegrationApplication');
|
|
124
|
+
exports.Interaction = require('./structures/Interaction');
|
|
125
|
+
exports.InteractionCollector = require('./structures/InteractionCollector');
|
|
126
|
+
exports.InteractionWebhook = require('./structures/InteractionWebhook');
|
|
108
127
|
exports.Invite = require('./structures/Invite');
|
|
109
128
|
exports.InviteStageInstance = require('./structures/InviteStageInstance');
|
|
110
129
|
exports.InviteGuild = require('./structures/InviteGuild');
|
|
111
130
|
exports.Message = require('./structures/Message').Message;
|
|
112
131
|
exports.MessageActionRow = require('./structures/MessageActionRow');
|
|
113
132
|
exports.MessageAttachment = require('./structures/MessageAttachment');
|
|
133
|
+
exports.MessageButton = require('./structures/MessageButton');
|
|
114
134
|
exports.MessageCollector = require('./structures/MessageCollector');
|
|
135
|
+
exports.MessageComponentInteraction = require('./structures/MessageComponentInteraction');
|
|
136
|
+
exports.MessageContextMenuInteraction = require('./structures/MessageContextMenuInteraction');
|
|
115
137
|
exports.MessageEmbed = require('./structures/MessageEmbed');
|
|
138
|
+
exports.WebEmbed = require('./structures/WebEmbed');
|
|
116
139
|
exports.MessageMentions = require('./structures/MessageMentions');
|
|
117
140
|
exports.MessagePayload = require('./structures/MessagePayload');
|
|
118
141
|
exports.MessageReaction = require('./structures/MessageReaction');
|
|
142
|
+
exports.MessageSelectMenu = require('./structures/MessageSelectMenu');
|
|
119
143
|
exports.Modal = require('./structures/Modal');
|
|
144
|
+
exports.ModalSubmitInteraction = require('./structures/ModalSubmitInteraction');
|
|
120
145
|
exports.NewsChannel = require('./structures/NewsChannel');
|
|
121
146
|
exports.OAuth2Guild = require('./structures/OAuth2Guild');
|
|
122
|
-
exports.
|
|
147
|
+
exports.PartialGroupDMChannel = require('./structures/PartialGroupDMChannel');
|
|
123
148
|
exports.PermissionOverwrites = require('./structures/PermissionOverwrites');
|
|
124
149
|
exports.Presence = require('./structures/Presence').Presence;
|
|
125
150
|
exports.ReactionCollector = require('./structures/ReactionCollector');
|
|
126
151
|
exports.ReactionEmoji = require('./structures/ReactionEmoji');
|
|
127
152
|
exports.RichPresenceAssets = require('./structures/Presence').RichPresenceAssets;
|
|
128
153
|
exports.Role = require('./structures/Role').Role;
|
|
154
|
+
exports.Session = require('./structures/Session');
|
|
155
|
+
// RPC
|
|
156
|
+
exports.getUUID = require('./structures/RichPresence').getUUID;
|
|
157
|
+
exports.CustomStatus = require('./structures/RichPresence').CustomStatus;
|
|
158
|
+
exports.RichPresence = require('./structures/RichPresence').RichPresence;
|
|
159
|
+
exports.SpotifyRPC = require('./structures/RichPresence').SpotifyRPC;
|
|
160
|
+
// SelectMenu
|
|
161
|
+
exports.ChannelSelectInteraction = require('./structures/SelectMenuInteraction').ChannelSelectInteraction;
|
|
162
|
+
exports.MentionableSelectInteraction = require('./structures/SelectMenuInteraction').MentionableSelectInteraction;
|
|
163
|
+
exports.RoleSelectInteraction = require('./structures/SelectMenuInteraction').RoleSelectInteraction;
|
|
164
|
+
exports.SelectMenuInteraction = require('./structures/SelectMenuInteraction').SelectMenuInteraction;
|
|
165
|
+
exports.UserSelectInteraction = require('./structures/SelectMenuInteraction').UserSelectInteraction;
|
|
166
|
+
//
|
|
129
167
|
exports.StageChannel = require('./structures/StageChannel');
|
|
130
168
|
exports.StageInstance = require('./structures/StageInstance').StageInstance;
|
|
131
169
|
exports.Sticker = require('./structures/Sticker').Sticker;
|
|
@@ -139,6 +177,7 @@ exports.ThreadChannel = require('./structures/ThreadChannel');
|
|
|
139
177
|
exports.ThreadMember = require('./structures/ThreadMember');
|
|
140
178
|
exports.Typing = require('./structures/Typing');
|
|
141
179
|
exports.User = require('./structures/User');
|
|
180
|
+
exports.UserContextMenuInteraction = require('./structures/UserContextMenuInteraction');
|
|
142
181
|
exports.VoiceChannel = require('./structures/VoiceChannel');
|
|
143
182
|
exports.VoiceRegion = require('./structures/VoiceRegion');
|
|
144
183
|
exports.VoiceState = require('./structures/VoiceState');
|
|
@@ -147,12 +186,4 @@ exports.Widget = require('./structures/Widget');
|
|
|
147
186
|
exports.WidgetMember = require('./structures/WidgetMember');
|
|
148
187
|
exports.WelcomeChannel = require('./structures/WelcomeChannel');
|
|
149
188
|
exports.WelcomeScreen = require('./structures/WelcomeScreen');
|
|
150
|
-
|
|
151
189
|
exports.WebSocket = require('./WebSocket');
|
|
152
|
-
|
|
153
|
-
exports.CustomStatus = require('./structures/RichPresence').CustomStatus;
|
|
154
|
-
exports.RichPresence = require('./structures/RichPresence').RichPresence;
|
|
155
|
-
exports.SpotifyRPC = require('./structures/RichPresence').SpotifyRPC;
|
|
156
|
-
exports.WebEmbed = require('./structures/WebEmbed');
|
|
157
|
-
exports.DiscordAuthWebsocket = require('./util/RemoteAuth');
|
|
158
|
-
exports.PurchasedFlags = require('./util/PurchasedFlags');
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { isJSONEncodable } = require('@discordjs/builders');
|
|
4
3
|
const { Collection } = require('@discordjs/collection');
|
|
5
4
|
const ApplicationCommandPermissionsManager = require('./ApplicationCommandPermissionsManager');
|
|
6
5
|
const CachedManager = require('./CachedManager');
|
|
@@ -14,14 +13,15 @@ const Permissions = require('../util/Permissions');
|
|
|
14
13
|
* @extends {CachedManager}
|
|
15
14
|
*/
|
|
16
15
|
class ApplicationCommandManager extends CachedManager {
|
|
17
|
-
constructor(client, iterable) {
|
|
16
|
+
constructor(client, iterable, user) {
|
|
18
17
|
super(client, ApplicationCommand, iterable);
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* The manager for permissions of arbitrary commands on arbitrary guilds
|
|
22
21
|
* @type {ApplicationCommandPermissionsManager}
|
|
23
22
|
*/
|
|
24
|
-
this.permissions = new ApplicationCommandPermissionsManager(this);
|
|
23
|
+
this.permissions = new ApplicationCommandPermissionsManager(this, user);
|
|
24
|
+
this.user = user;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -43,7 +43,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
43
43
|
* @private
|
|
44
44
|
*/
|
|
45
45
|
commandPath({ id, guildId } = {}) {
|
|
46
|
-
let path = this.client.api.applications(this.
|
|
46
|
+
let path = this.client.api.applications(this.user.id);
|
|
47
47
|
if (this.guild ?? guildId) path = path.guilds(this.guild?.id ?? guildId);
|
|
48
48
|
return id ? path.commands(id) : path.commands;
|
|
49
49
|
}
|
|
@@ -58,7 +58,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
58
58
|
/* eslint-disable max-len */
|
|
59
59
|
/**
|
|
60
60
|
* Data that resolves to the data of an ApplicationCommand
|
|
61
|
-
* @typedef {
|
|
61
|
+
* @typedef {ApplicationCommandDataResolvable|SlashCommandBuilder|ContextMenuCommandBuilder} ApplicationCommandDataResolvable
|
|
62
62
|
*/
|
|
63
63
|
/* eslint-enable max-len */
|
|
64
64
|
|
|
@@ -94,6 +94,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
94
94
|
* .catch(console.error);
|
|
95
95
|
*/
|
|
96
96
|
async fetch(id, { guildId, cache = true, force = false, locale, withLocalizations } = {}) {
|
|
97
|
+
// Change from user.createDM to opcode (risky action)
|
|
97
98
|
if (typeof id === 'object') {
|
|
98
99
|
({ guildId, cache = true, locale, withLocalizations } = id);
|
|
99
100
|
} else if (id) {
|
|
@@ -101,10 +102,11 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
101
102
|
const existing = this.cache.get(id);
|
|
102
103
|
if (existing) return existing;
|
|
103
104
|
}
|
|
105
|
+
await this.user.createDM().catch(() => {});
|
|
104
106
|
const command = await this.commandPath({ id, guildId }).get();
|
|
105
107
|
return this._add(command, cache);
|
|
106
108
|
}
|
|
107
|
-
|
|
109
|
+
await this.user.createDM().catch(() => {});
|
|
108
110
|
const data = await this.commandPath({ guildId }).get({
|
|
109
111
|
headers: {
|
|
110
112
|
'X-Discord-Locale': locale,
|
|
@@ -130,6 +132,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
130
132
|
* .catch(console.error);
|
|
131
133
|
*/
|
|
132
134
|
async create(command, guildId) {
|
|
135
|
+
if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
133
136
|
const data = await this.commandPath({ guildId }).post({
|
|
134
137
|
data: this.constructor.transformCommand(command),
|
|
135
138
|
});
|
|
@@ -159,6 +162,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
159
162
|
* .catch(console.error);
|
|
160
163
|
*/
|
|
161
164
|
async set(commands, guildId) {
|
|
165
|
+
if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
162
166
|
const data = await this.commandPath({ guildId }).put({
|
|
163
167
|
data: commands.map(c => this.constructor.transformCommand(c)),
|
|
164
168
|
});
|
|
@@ -181,6 +185,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
181
185
|
* .catch(console.error);
|
|
182
186
|
*/
|
|
183
187
|
async edit(command, data, guildId) {
|
|
188
|
+
if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
184
189
|
const id = this.resolveId(command);
|
|
185
190
|
if (!id) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
|
186
191
|
|
|
@@ -203,6 +208,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
203
208
|
* .catch(console.error);
|
|
204
209
|
*/
|
|
205
210
|
async delete(command, guildId) {
|
|
211
|
+
if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
206
212
|
const id = this.resolveId(command);
|
|
207
213
|
if (!id) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
|
208
214
|
|
|
@@ -220,8 +226,6 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
220
226
|
* @private
|
|
221
227
|
*/
|
|
222
228
|
static transformCommand(command) {
|
|
223
|
-
if (isJSONEncodable(command)) return command.toJSON();
|
|
224
|
-
|
|
225
229
|
let default_member_permissions;
|
|
226
230
|
|
|
227
231
|
if ('default_member_permissions' in command) {
|
|
@@ -236,7 +240,6 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
236
240
|
? new Permissions(command.defaultMemberPermissions).bitfield.toString()
|
|
237
241
|
: command.defaultMemberPermissions;
|
|
238
242
|
}
|
|
239
|
-
|
|
240
243
|
return {
|
|
241
244
|
name: command.name,
|
|
242
245
|
name_localizations: command.nameLocalizations ?? command.name_localizations,
|
|
@@ -10,7 +10,7 @@ const { ApplicationCommandPermissionTypes, APIErrors } = require('../util/Consta
|
|
|
10
10
|
* @extends {BaseManager}
|
|
11
11
|
*/
|
|
12
12
|
class ApplicationCommandPermissionsManager extends BaseManager {
|
|
13
|
-
constructor(manager) {
|
|
13
|
+
constructor(manager, user) {
|
|
14
14
|
super(manager.client);
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -37,6 +37,8 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
37
37
|
* @type {?Snowflake}
|
|
38
38
|
*/
|
|
39
39
|
this.commandId = manager.id ?? null;
|
|
40
|
+
|
|
41
|
+
this.user = user;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/**
|
|
@@ -47,7 +49,10 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
47
49
|
* @private
|
|
48
50
|
*/
|
|
49
51
|
permissionsPath(guildId, commandId) {
|
|
50
|
-
return this.client.api
|
|
52
|
+
return this.client.api
|
|
53
|
+
.applications(typeof this.user === 'string' ? this.user : this.user.id)
|
|
54
|
+
.guilds(guildId)
|
|
55
|
+
.commands(commandId).permissions;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
/**
|
|
@@ -159,6 +164,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
159
164
|
* .catch(console.error);
|
|
160
165
|
*/
|
|
161
166
|
async set({ guild, command, permissions, fullPermissions } = {}) {
|
|
167
|
+
if (!this.manager.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
162
168
|
const { guildId, commandId } = this._validateOptions(guild, command);
|
|
163
169
|
|
|
164
170
|
if (commandId) {
|
|
@@ -220,6 +226,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
220
226
|
* .catch(console.error);
|
|
221
227
|
*/
|
|
222
228
|
async add({ guild, command, permissions }) {
|
|
229
|
+
if (!this.manager.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
223
230
|
const { guildId, commandId } = this._validateOptions(guild, command);
|
|
224
231
|
if (!commandId) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
|
225
232
|
if (!Array.isArray(permissions)) {
|
|
@@ -271,12 +278,13 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
271
278
|
* .catch(console.error);
|
|
272
279
|
*/
|
|
273
280
|
async remove({ guild, command, users, roles }) {
|
|
281
|
+
if (!this.manager.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
274
282
|
const { guildId, commandId } = this._validateOptions(guild, command);
|
|
275
283
|
if (!commandId) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
|
276
284
|
|
|
277
285
|
if (!users && !roles) throw new TypeError('INVALID_TYPE', 'users OR roles', 'Array or Resolvable', true);
|
|
278
286
|
|
|
279
|
-
|
|
287
|
+
const resolvedIds = [];
|
|
280
288
|
if (Array.isArray(users)) {
|
|
281
289
|
users.forEach(user => {
|
|
282
290
|
const userId = this.client.users.resolveId(user);
|
|
@@ -113,13 +113,14 @@ class ChannelManager extends CachedManager {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
const data = await this.client.api.channels(id).get();
|
|
116
|
+
// Delete in cache
|
|
117
|
+
this._remove(id);
|
|
116
118
|
return this._add(data, null, { cache, allowUnknownGuild });
|
|
117
119
|
}
|
|
118
|
-
|
|
119
120
|
/**
|
|
120
121
|
* Create Group DM
|
|
121
122
|
* @param {UserResolvable[]} recipients Array of recipients
|
|
122
|
-
* @returns {Promise<
|
|
123
|
+
* @returns {Promise<PartialGroupDMChannel>} Channel
|
|
123
124
|
*/
|
|
124
125
|
async createGroupDM(recipients) {
|
|
125
126
|
// Check
|
|
@@ -127,6 +128,7 @@ class ChannelManager extends CachedManager {
|
|
|
127
128
|
recipients = recipients
|
|
128
129
|
.map(r => this.client.users.resolveId(r))
|
|
129
130
|
.filter(r => r && this.client.relationships.cache.get(r) == RelationshipTypes.FRIEND);
|
|
131
|
+
if (recipients.length > 9) throw new Error('Invalid Users length (2 - 9)');
|
|
130
132
|
const data = await this.client.api.users['@me'].channels.post({
|
|
131
133
|
data: { recipients },
|
|
132
134
|
});
|