djs-selfbot-v13 3.1.7 → 3.1.8
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/LICENSE +1 -1
- package/README.md +18 -45
- package/package.json +8 -37
- package/src/client/BaseClient.js +2 -3
- package/src/client/Client.js +187 -539
- 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/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 +7 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
- package/src/client/websocket/handlers/READY.js +47 -137
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +6 -4
- 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 +15 -20
- package/src/errors/Messages.js +24 -69
- package/src/index.js +12 -43
- package/src/managers/ApplicationCommandManager.js +9 -12
- package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
- package/src/managers/ChannelManager.js +3 -4
- package/src/managers/ClientUserSettingManager.js +161 -279
- package/src/managers/GuildBanManager.js +1 -1
- package/src/managers/GuildChannelManager.js +2 -0
- package/src/managers/GuildForumThreadManager.js +22 -28
- package/src/managers/GuildMemberManager.js +40 -216
- 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 +81 -74
- 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 +42 -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 +12 -8
- package/src/structures/ClientUser.js +117 -336
- 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 +228 -202
- 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 +4 -46
- package/src/structures/MessageReaction.js +1 -1
- package/src/structures/MessageSelectMenu.js +1 -252
- package/src/structures/Modal.js +75 -180
- package/src/structures/Presence.js +2 -2
- package/src/structures/RichPresence.js +14 -34
- 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 +117 -345
- 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 +411 -256
- package/src/util/ApplicationFlags.js +1 -1
- package/src/util/AttachmentFlags.js +38 -0
- package/src/util/Constants.js +106 -284
- 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 -68
- package/src/util/Permissions.js +5 -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 +76 -36
- package/typings/enums.d.ts +18 -73
- package/typings/index.d.ts +873 -1225
- 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/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
package/src/errors/Messages.js
CHANGED
|
@@ -11,8 +11,6 @@ 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
|
-
|
|
16
14
|
WS_CLOSE_REQUESTED: 'WebSocket closed due to user request.',
|
|
17
15
|
WS_CONNECTION_EXISTS: 'There is already an existing WebSocket connection.',
|
|
18
16
|
WS_NOT_OPEN: (data = 'data') => `WebSocket not open to send ${data}`,
|
|
@@ -20,8 +18,8 @@ const Messages = {
|
|
|
20
18
|
|
|
21
19
|
BITFIELD_INVALID: bit => `Invalid bitfield flag or number: ${bit}.`,
|
|
22
20
|
|
|
23
|
-
SHARDING_INVALID: 'Invalid shard settings were provided.',
|
|
24
|
-
SHARDING_REQUIRED: 'This session would have handled too many guilds - Sharding is required.',
|
|
21
|
+
SHARDING_INVALID: '[Bot Token] Invalid shard settings were provided.',
|
|
22
|
+
SHARDING_REQUIRED: '[Bot Token] This session would have handled too many guilds - Sharding is required.',
|
|
25
23
|
INVALID_INTENTS: '[Bot Token] Invalid intent provided for WebSocket intents.',
|
|
26
24
|
DISALLOWED_INTENTS: '[Bot Token] Privileged intent provided is not enabled or whitelisted.',
|
|
27
25
|
SHARDING_NO_SHARDS: 'No shards have been spawned.',
|
|
@@ -49,12 +47,6 @@ const Messages = {
|
|
|
49
47
|
EMBED_FOOTER_TEXT: 'MessageEmbed footer text must be a string.',
|
|
50
48
|
EMBED_DESCRIPTION: 'MessageEmbed description must be a string.',
|
|
51
49
|
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.',
|
|
58
50
|
|
|
59
51
|
BUTTON_LABEL: 'MessageButton label must be a string',
|
|
60
52
|
BUTTON_URL: 'MessageButton URL must be a string',
|
|
@@ -66,13 +58,20 @@ const Messages = {
|
|
|
66
58
|
SELECT_OPTION_VALUE: 'MessageSelectOption value must be a string',
|
|
67
59
|
SELECT_OPTION_DESCRIPTION: 'MessageSelectOption description must be a string',
|
|
68
60
|
|
|
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!',
|
|
76
75
|
|
|
77
76
|
VOICE_NOT_STAGE_CHANNEL: 'You are only allowed to do this in stage channels.',
|
|
78
77
|
|
|
@@ -102,17 +101,11 @@ const Messages = {
|
|
|
102
101
|
GUILD_CHANNEL_UNOWNED: "The fetched channel does not belong to this manager's guild.",
|
|
103
102
|
GUILD_OWNED: 'Guild is owned by the client.',
|
|
104
103
|
GUILD_MEMBERS_TIMEOUT: "Members didn't arrive in time.",
|
|
105
|
-
GUILD_APPLICATION_COMMANDS_SEARCH_TIMEOUT: "Application commands didn't arrive in time.",
|
|
106
104
|
GUILD_UNCACHED_ME: 'The client user as a member of this guild is uncached.',
|
|
107
105
|
CHANNEL_NOT_CACHED: 'Could not find the channel where this message came from in the cache!',
|
|
108
106
|
STAGE_CHANNEL_RESOLVE: 'Could not resolve channel to a stage channel.',
|
|
109
107
|
GUILD_SCHEDULED_EVENT_RESOLVE: 'Could not resolve the guild scheduled event.',
|
|
110
108
|
|
|
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
|
-
|
|
116
109
|
INVALID_TYPE: (name, expected, an = false) => `Supplied ${name} is not a${an ? 'n' : ''} ${expected}.`,
|
|
117
110
|
INVALID_ELEMENT: (type, name, elem) => `Supplied ${type} ${name} includes an invalid element: ${elem}`,
|
|
118
111
|
|
|
@@ -140,10 +133,6 @@ const Messages = {
|
|
|
140
133
|
|
|
141
134
|
INVITE_NOT_FOUND: 'Could not find the requested invite.',
|
|
142
135
|
|
|
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
|
-
|
|
147
136
|
DELETE_GROUP_DM_CHANNEL: "Bots don't have access to Group DM Channels and cannot delete them",
|
|
148
137
|
FETCH_GROUP_DM_CHANNEL: "Bots don't have access to Group DM Channels and cannot fetch them",
|
|
149
138
|
|
|
@@ -156,8 +145,6 @@ const Messages = {
|
|
|
156
145
|
|
|
157
146
|
INTERACTION_ALREADY_REPLIED: 'The reply to this interaction has already been sent or deferred.',
|
|
158
147
|
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.',
|
|
161
148
|
|
|
162
149
|
COMMAND_INTERACTION_OPTION_NOT_FOUND: name => `Required option "${name}" not found.`,
|
|
163
150
|
COMMAND_INTERACTION_OPTION_TYPE: (name, type, expected) =>
|
|
@@ -168,60 +155,28 @@ const Messages = {
|
|
|
168
155
|
COMMAND_INTERACTION_OPTION_NO_SUB_COMMAND_GROUP: 'No subcommand group specified for interaction.',
|
|
169
156
|
AUTOCOMPLETE_INTERACTION_OPTION_NO_FOCUSED_OPTION: 'No focused option for autocomplete interaction.',
|
|
170
157
|
|
|
171
|
-
INVITE_MISSING_SCOPES: 'At least one valid scope must be provided for the invite',
|
|
172
|
-
|
|
173
|
-
NOT_IMPLEMENTED: (what, name) => `Method ${what} not implemented on ${name}.`,
|
|
174
|
-
|
|
175
|
-
SWEEP_FILTER_RETURN: 'The return value of the sweepFilter function was not false or a Function',
|
|
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
158
|
MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND: customId => `Required field with custom id "${customId}" not found.`,
|
|
203
159
|
MODAL_SUBMIT_INTERACTION_FIELD_TYPE: (customId, type, expected) =>
|
|
204
160
|
`Field with custom id "${customId}" is of type: ${type}; expected ${expected}.`,
|
|
205
161
|
|
|
206
|
-
|
|
207
|
-
INVALID_URL: url =>
|
|
208
|
-
`Invalid URL: ${url}.\nMake sure you are using a valid URL (https://discord.com/oauth2/authorize?...)`,
|
|
162
|
+
INVITE_MISSING_SCOPES: 'At least one valid scope must be provided for the invite',
|
|
209
163
|
|
|
210
|
-
|
|
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.',
|
|
164
|
+
NOT_IMPLEMENTED: (what, name) => `Method ${what} not implemented on ${name}.`,
|
|
214
165
|
|
|
215
|
-
|
|
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',
|
|
166
|
+
SWEEP_FILTER_RETURN: 'The return value of the sweepFilter function was not false or a Function',
|
|
220
167
|
|
|
221
|
-
|
|
168
|
+
GUILD_FORUM_MESSAGE_REQUIRED: 'You must provide a message to create a guild forum thread',
|
|
222
169
|
|
|
223
|
-
|
|
224
|
-
|
|
170
|
+
// Selfbot
|
|
171
|
+
INVALID_USER_API: 'User accounts cannot use this endpoint',
|
|
172
|
+
INVALID_COMMAND_NAME: allCMD => `Could not parse subGroupCommand and subCommand due to too long: ${allCMD.join(' ')}`,
|
|
173
|
+
INVALID_SLASH_COMMAND_CHOICES: (parentOptions, value) =>
|
|
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',
|
|
225
180
|
};
|
|
226
181
|
|
|
227
182
|
for (const [name, message] of Object.entries(Messages)) register(name, message);
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
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
|
-
|
|
9
3
|
// "Root" classes (starting points)
|
|
10
4
|
exports.BaseClient = require('./client/BaseClient');
|
|
11
5
|
exports.Client = require('./client/Client');
|
|
@@ -15,9 +9,9 @@ exports.ShardingManager = require('./sharding/ShardingManager');
|
|
|
15
9
|
exports.WebhookClient = require('./client/WebhookClient');
|
|
16
10
|
|
|
17
11
|
// Utilities
|
|
18
|
-
exports.DiscordRPCServer = require('./util/arRPC/index');
|
|
19
12
|
exports.ActivityFlags = require('./util/ActivityFlags');
|
|
20
13
|
exports.ApplicationFlags = require('./util/ApplicationFlags');
|
|
14
|
+
exports.AttachmentFlags = require('./util/AttachmentFlags');
|
|
21
15
|
exports.BaseManager = require('./managers/BaseManager');
|
|
22
16
|
exports.BitField = require('./util/BitField');
|
|
23
17
|
exports.Collection = require('@discordjs/collection').Collection;
|
|
@@ -33,6 +27,7 @@ exports.MessageFlags = require('./util/MessageFlags');
|
|
|
33
27
|
exports.Options = require('./util/Options');
|
|
34
28
|
exports.Permissions = require('./util/Permissions');
|
|
35
29
|
exports.RateLimitError = require('./rest/RateLimitError');
|
|
30
|
+
exports.RoleFlags = require('./util/RoleFlags');
|
|
36
31
|
exports.SnowflakeUtil = require('./util/SnowflakeUtil');
|
|
37
32
|
exports.Sweepers = require('./util/Sweepers');
|
|
38
33
|
exports.SystemChannelFlags = require('./util/SystemChannelFlags');
|
|
@@ -40,8 +35,6 @@ exports.ThreadMemberFlags = require('./util/ThreadMemberFlags');
|
|
|
40
35
|
exports.UserFlags = require('./util/UserFlags');
|
|
41
36
|
exports.Util = require('./util/Util');
|
|
42
37
|
exports.version = require('../package.json').version;
|
|
43
|
-
exports.DiscordAuthWebsocket = require('./util/RemoteAuth');
|
|
44
|
-
exports.PurchasedFlags = require('./util/PurchasedFlags');
|
|
45
38
|
|
|
46
39
|
// Managers
|
|
47
40
|
exports.ApplicationCommandManager = require('./managers/ApplicationCommandManager');
|
|
@@ -52,7 +45,6 @@ exports.CachedManager = require('./managers/CachedManager');
|
|
|
52
45
|
exports.ChannelManager = require('./managers/ChannelManager');
|
|
53
46
|
exports.ClientVoiceManager = require('./client/voice/ClientVoiceManager');
|
|
54
47
|
exports.DataManager = require('./managers/DataManager');
|
|
55
|
-
exports.GuildApplicationCommandManager = require('./managers/GuildApplicationCommandManager');
|
|
56
48
|
exports.GuildBanManager = require('./managers/GuildBanManager');
|
|
57
49
|
exports.GuildChannelManager = require('./managers/GuildChannelManager');
|
|
58
50
|
exports.GuildEmojiManager = require('./managers/GuildEmojiManager');
|
|
@@ -69,7 +61,6 @@ exports.PresenceManager = require('./managers/PresenceManager');
|
|
|
69
61
|
exports.ReactionManager = require('./managers/ReactionManager');
|
|
70
62
|
exports.ReactionUserManager = require('./managers/ReactionUserManager');
|
|
71
63
|
exports.RoleManager = require('./managers/RoleManager');
|
|
72
|
-
exports.SessionManager = require('./managers/SessionManager');
|
|
73
64
|
exports.StageInstanceManager = require('./managers/StageInstanceManager');
|
|
74
65
|
exports.ThreadManager = require('./managers/ThreadManager');
|
|
75
66
|
exports.ThreadMemberManager = require('./managers/ThreadMemberManager');
|
|
@@ -78,6 +69,7 @@ exports.VoiceStateManager = require('./managers/VoiceStateManager');
|
|
|
78
69
|
exports.WebSocketManager = require('./client/websocket/WebSocketManager');
|
|
79
70
|
exports.WebSocketShard = require('./client/websocket/WebSocketShard');
|
|
80
71
|
exports.RelationshipManager = require('./managers/RelationshipManager');
|
|
72
|
+
exports.UserNoteManager = require('./managers/UserNoteManager');
|
|
81
73
|
|
|
82
74
|
// Structures
|
|
83
75
|
exports.Activity = require('./structures/Presence').Activity;
|
|
@@ -86,26 +78,18 @@ exports.Application = require('./structures/interfaces/Application');
|
|
|
86
78
|
exports.ApplicationCommand = require('./structures/ApplicationCommand');
|
|
87
79
|
exports.ApplicationRoleConnectionMetadata =
|
|
88
80
|
require('./structures/ApplicationRoleConnectionMetadata').ApplicationRoleConnectionMetadata;
|
|
89
|
-
exports.AutocompleteInteraction = require('./structures/AutocompleteInteraction');
|
|
90
81
|
exports.AutoModerationActionExecution = require('./structures/AutoModerationActionExecution');
|
|
91
82
|
exports.AutoModerationRule = require('./structures/AutoModerationRule');
|
|
92
83
|
exports.Base = require('./structures/Base');
|
|
93
|
-
exports.BaseCommandInteraction = require('./structures/BaseCommandInteraction');
|
|
94
84
|
exports.BaseGuild = require('./structures/BaseGuild');
|
|
95
85
|
exports.BaseGuildEmoji = require('./structures/BaseGuildEmoji');
|
|
96
86
|
exports.BaseGuildTextChannel = require('./structures/BaseGuildTextChannel');
|
|
97
87
|
exports.BaseGuildVoiceChannel = require('./structures/BaseGuildVoiceChannel');
|
|
98
|
-
exports.BaseMessageComponent = require('./structures/BaseMessageComponent');
|
|
99
|
-
exports.ButtonInteraction = require('./structures/ButtonInteraction');
|
|
100
88
|
exports.CategoryChannel = require('./structures/CategoryChannel');
|
|
101
89
|
exports.Channel = require('./structures/Channel').Channel;
|
|
102
|
-
exports.ClientApplication = require('./structures/ClientApplication');
|
|
103
90
|
exports.ClientPresence = require('./structures/ClientPresence');
|
|
104
91
|
exports.ClientUser = require('./structures/ClientUser');
|
|
105
92
|
exports.Collector = require('./structures/interfaces/Collector');
|
|
106
|
-
exports.CommandInteraction = require('./structures/CommandInteraction');
|
|
107
|
-
exports.CommandInteractionOptionResolver = require('./structures/CommandInteractionOptionResolver');
|
|
108
|
-
exports.ContextMenuInteraction = require('./structures/ContextMenuInteraction');
|
|
109
93
|
exports.DMChannel = require('./structures/DMChannel');
|
|
110
94
|
exports.Emoji = require('./structures/Emoji').Emoji;
|
|
111
95
|
exports.Guild = require('./structures/Guild').Guild;
|
|
@@ -121,49 +105,27 @@ exports.GuildScheduledEvent = require('./structures/GuildScheduledEvent').GuildS
|
|
|
121
105
|
exports.GuildTemplate = require('./structures/GuildTemplate');
|
|
122
106
|
exports.Integration = require('./structures/Integration');
|
|
123
107
|
exports.IntegrationApplication = require('./structures/IntegrationApplication');
|
|
124
|
-
exports.Interaction = require('./structures/Interaction');
|
|
125
|
-
exports.InteractionCollector = require('./structures/InteractionCollector');
|
|
126
|
-
exports.InteractionWebhook = require('./structures/InteractionWebhook');
|
|
127
108
|
exports.Invite = require('./structures/Invite');
|
|
128
109
|
exports.InviteStageInstance = require('./structures/InviteStageInstance');
|
|
129
110
|
exports.InviteGuild = require('./structures/InviteGuild');
|
|
130
111
|
exports.Message = require('./structures/Message').Message;
|
|
131
112
|
exports.MessageActionRow = require('./structures/MessageActionRow');
|
|
132
113
|
exports.MessageAttachment = require('./structures/MessageAttachment');
|
|
133
|
-
exports.MessageButton = require('./structures/MessageButton');
|
|
134
114
|
exports.MessageCollector = require('./structures/MessageCollector');
|
|
135
|
-
exports.MessageComponentInteraction = require('./structures/MessageComponentInteraction');
|
|
136
|
-
exports.MessageContextMenuInteraction = require('./structures/MessageContextMenuInteraction');
|
|
137
115
|
exports.MessageEmbed = require('./structures/MessageEmbed');
|
|
138
|
-
exports.WebEmbed = require('./structures/WebEmbed');
|
|
139
116
|
exports.MessageMentions = require('./structures/MessageMentions');
|
|
140
117
|
exports.MessagePayload = require('./structures/MessagePayload');
|
|
141
118
|
exports.MessageReaction = require('./structures/MessageReaction');
|
|
142
|
-
exports.MessageSelectMenu = require('./structures/MessageSelectMenu');
|
|
143
119
|
exports.Modal = require('./structures/Modal');
|
|
144
|
-
exports.ModalSubmitInteraction = require('./structures/ModalSubmitInteraction');
|
|
145
120
|
exports.NewsChannel = require('./structures/NewsChannel');
|
|
146
121
|
exports.OAuth2Guild = require('./structures/OAuth2Guild');
|
|
147
|
-
exports.
|
|
122
|
+
exports.GroupDMChannel = require('./structures/GroupDMChannel');
|
|
148
123
|
exports.PermissionOverwrites = require('./structures/PermissionOverwrites');
|
|
149
124
|
exports.Presence = require('./structures/Presence').Presence;
|
|
150
125
|
exports.ReactionCollector = require('./structures/ReactionCollector');
|
|
151
126
|
exports.ReactionEmoji = require('./structures/ReactionEmoji');
|
|
152
127
|
exports.RichPresenceAssets = require('./structures/Presence').RichPresenceAssets;
|
|
153
128
|
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
|
-
//
|
|
167
129
|
exports.StageChannel = require('./structures/StageChannel');
|
|
168
130
|
exports.StageInstance = require('./structures/StageInstance').StageInstance;
|
|
169
131
|
exports.Sticker = require('./structures/Sticker').Sticker;
|
|
@@ -177,7 +139,6 @@ exports.ThreadChannel = require('./structures/ThreadChannel');
|
|
|
177
139
|
exports.ThreadMember = require('./structures/ThreadMember');
|
|
178
140
|
exports.Typing = require('./structures/Typing');
|
|
179
141
|
exports.User = require('./structures/User');
|
|
180
|
-
exports.UserContextMenuInteraction = require('./structures/UserContextMenuInteraction');
|
|
181
142
|
exports.VoiceChannel = require('./structures/VoiceChannel');
|
|
182
143
|
exports.VoiceRegion = require('./structures/VoiceRegion');
|
|
183
144
|
exports.VoiceState = require('./structures/VoiceState');
|
|
@@ -186,4 +147,12 @@ exports.Widget = require('./structures/Widget');
|
|
|
186
147
|
exports.WidgetMember = require('./structures/WidgetMember');
|
|
187
148
|
exports.WelcomeChannel = require('./structures/WelcomeChannel');
|
|
188
149
|
exports.WelcomeScreen = require('./structures/WelcomeScreen');
|
|
150
|
+
|
|
189
151
|
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,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { isJSONEncodable } = require('@discordjs/builders');
|
|
3
4
|
const { Collection } = require('@discordjs/collection');
|
|
4
5
|
const ApplicationCommandPermissionsManager = require('./ApplicationCommandPermissionsManager');
|
|
5
6
|
const CachedManager = require('./CachedManager');
|
|
@@ -13,15 +14,14 @@ const Permissions = require('../util/Permissions');
|
|
|
13
14
|
* @extends {CachedManager}
|
|
14
15
|
*/
|
|
15
16
|
class ApplicationCommandManager extends CachedManager {
|
|
16
|
-
constructor(client, iterable
|
|
17
|
+
constructor(client, iterable) {
|
|
17
18
|
super(client, ApplicationCommand, iterable);
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* The manager for permissions of arbitrary commands on arbitrary guilds
|
|
21
22
|
* @type {ApplicationCommandPermissionsManager}
|
|
22
23
|
*/
|
|
23
|
-
this.permissions = new ApplicationCommandPermissionsManager(this
|
|
24
|
-
this.user = user;
|
|
24
|
+
this.permissions = new ApplicationCommandPermissionsManager(this);
|
|
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.client.application.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 {ApplicationCommandData|APIApplicationCommand|SlashCommandBuilder|ContextMenuCommandBuilder} ApplicationCommandDataResolvable
|
|
62
62
|
*/
|
|
63
63
|
/* eslint-enable max-len */
|
|
64
64
|
|
|
@@ -94,7 +94,6 @@ 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)
|
|
98
97
|
if (typeof id === 'object') {
|
|
99
98
|
({ guildId, cache = true, locale, withLocalizations } = id);
|
|
100
99
|
} else if (id) {
|
|
@@ -102,11 +101,10 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
102
101
|
const existing = this.cache.get(id);
|
|
103
102
|
if (existing) return existing;
|
|
104
103
|
}
|
|
105
|
-
await this.user.createDM().catch(() => {});
|
|
106
104
|
const command = await this.commandPath({ id, guildId }).get();
|
|
107
105
|
return this._add(command, cache);
|
|
108
106
|
}
|
|
109
|
-
|
|
107
|
+
|
|
110
108
|
const data = await this.commandPath({ guildId }).get({
|
|
111
109
|
headers: {
|
|
112
110
|
'X-Discord-Locale': locale,
|
|
@@ -132,7 +130,6 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
132
130
|
* .catch(console.error);
|
|
133
131
|
*/
|
|
134
132
|
async create(command, guildId) {
|
|
135
|
-
if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
136
133
|
const data = await this.commandPath({ guildId }).post({
|
|
137
134
|
data: this.constructor.transformCommand(command),
|
|
138
135
|
});
|
|
@@ -162,7 +159,6 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
162
159
|
* .catch(console.error);
|
|
163
160
|
*/
|
|
164
161
|
async set(commands, guildId) {
|
|
165
|
-
if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
166
162
|
const data = await this.commandPath({ guildId }).put({
|
|
167
163
|
data: commands.map(c => this.constructor.transformCommand(c)),
|
|
168
164
|
});
|
|
@@ -185,7 +181,6 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
185
181
|
* .catch(console.error);
|
|
186
182
|
*/
|
|
187
183
|
async edit(command, data, guildId) {
|
|
188
|
-
if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
189
184
|
const id = this.resolveId(command);
|
|
190
185
|
if (!id) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
|
191
186
|
|
|
@@ -208,7 +203,6 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
208
203
|
* .catch(console.error);
|
|
209
204
|
*/
|
|
210
205
|
async delete(command, guildId) {
|
|
211
|
-
if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
212
206
|
const id = this.resolveId(command);
|
|
213
207
|
if (!id) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
|
214
208
|
|
|
@@ -226,6 +220,8 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
226
220
|
* @private
|
|
227
221
|
*/
|
|
228
222
|
static transformCommand(command) {
|
|
223
|
+
if (isJSONEncodable(command)) return command.toJSON();
|
|
224
|
+
|
|
229
225
|
let default_member_permissions;
|
|
230
226
|
|
|
231
227
|
if ('default_member_permissions' in command) {
|
|
@@ -240,6 +236,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
240
236
|
? new Permissions(command.defaultMemberPermissions).bitfield.toString()
|
|
241
237
|
: command.defaultMemberPermissions;
|
|
242
238
|
}
|
|
239
|
+
|
|
243
240
|
return {
|
|
244
241
|
name: command.name,
|
|
245
242
|
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) {
|
|
14
14
|
super(manager.client);
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -37,8 +37,6 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
37
37
|
* @type {?Snowflake}
|
|
38
38
|
*/
|
|
39
39
|
this.commandId = manager.id ?? null;
|
|
40
|
-
|
|
41
|
-
this.user = user;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
/**
|
|
@@ -49,10 +47,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
49
47
|
* @private
|
|
50
48
|
*/
|
|
51
49
|
permissionsPath(guildId, commandId) {
|
|
52
|
-
return this.client.api
|
|
53
|
-
.applications(typeof this.user === 'string' ? this.user : this.user.id)
|
|
54
|
-
.guilds(guildId)
|
|
55
|
-
.commands(commandId).permissions;
|
|
50
|
+
return this.client.api.applications(this.client.application.id).guilds(guildId).commands(commandId).permissions;
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
/**
|
|
@@ -164,7 +159,6 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
164
159
|
* .catch(console.error);
|
|
165
160
|
*/
|
|
166
161
|
async set({ guild, command, permissions, fullPermissions } = {}) {
|
|
167
|
-
if (!this.manager.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
168
162
|
const { guildId, commandId } = this._validateOptions(guild, command);
|
|
169
163
|
|
|
170
164
|
if (commandId) {
|
|
@@ -226,7 +220,6 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
226
220
|
* .catch(console.error);
|
|
227
221
|
*/
|
|
228
222
|
async add({ guild, command, permissions }) {
|
|
229
|
-
if (!this.manager.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
230
223
|
const { guildId, commandId } = this._validateOptions(guild, command);
|
|
231
224
|
if (!commandId) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
|
232
225
|
if (!Array.isArray(permissions)) {
|
|
@@ -278,13 +271,12 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
278
271
|
* .catch(console.error);
|
|
279
272
|
*/
|
|
280
273
|
async remove({ guild, command, users, roles }) {
|
|
281
|
-
if (!this.manager.client.user.bot) throw new Error('INVALID_USER_METHOD');
|
|
282
274
|
const { guildId, commandId } = this._validateOptions(guild, command);
|
|
283
275
|
if (!commandId) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
|
284
276
|
|
|
285
277
|
if (!users && !roles) throw new TypeError('INVALID_TYPE', 'users OR roles', 'Array or Resolvable', true);
|
|
286
278
|
|
|
287
|
-
|
|
279
|
+
let resolvedIds = [];
|
|
288
280
|
if (Array.isArray(users)) {
|
|
289
281
|
users.forEach(user => {
|
|
290
282
|
const userId = this.client.users.resolveId(user);
|
|
@@ -113,14 +113,13 @@ 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);
|
|
118
116
|
return this._add(data, null, { cache, allowUnknownGuild });
|
|
119
117
|
}
|
|
118
|
+
|
|
120
119
|
/**
|
|
121
120
|
* Create Group DM
|
|
122
121
|
* @param {UserResolvable[]} recipients Array of recipients
|
|
123
|
-
* @returns {Promise<
|
|
122
|
+
* @returns {Promise<GroupDMChannel>} Channel
|
|
124
123
|
*/
|
|
125
124
|
async createGroupDM(recipients) {
|
|
126
125
|
// Check
|
|
@@ -128,7 +127,7 @@ class ChannelManager extends CachedManager {
|
|
|
128
127
|
recipients = recipients
|
|
129
128
|
.map(r => this.client.users.resolveId(r))
|
|
130
129
|
.filter(r => r && this.client.relationships.cache.get(r) == RelationshipTypes.FRIEND);
|
|
131
|
-
if (recipients.length > 9) throw new Error('Invalid Users length (
|
|
130
|
+
if (recipients.length < 1 || recipients.length > 9) throw new Error('Invalid Users length (1 - 9)');
|
|
132
131
|
const data = await this.client.api.users['@me'].channels.post({
|
|
133
132
|
data: { recipients },
|
|
134
133
|
});
|