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
|
@@ -5,14 +5,12 @@ import {
|
|
|
5
5
|
APIApplication,
|
|
6
6
|
APIApplicationCommand,
|
|
7
7
|
APIApplicationCommandInteraction,
|
|
8
|
-
APIAttachment,
|
|
9
8
|
APIAuditLog,
|
|
10
9
|
APIAuditLogEntry,
|
|
11
10
|
APIBan,
|
|
12
11
|
APIChannel,
|
|
13
12
|
APIEmoji,
|
|
14
13
|
APIExtendedInvite,
|
|
15
|
-
APIGuild,
|
|
16
14
|
APIGuildIntegration,
|
|
17
15
|
APIGuildIntegrationApplication,
|
|
18
16
|
APIGuildMember,
|
|
@@ -76,21 +74,26 @@ import {
|
|
|
76
74
|
RESTPostAPIWebhookWithTokenJSONBody,
|
|
77
75
|
Snowflake,
|
|
78
76
|
APIGuildScheduledEvent,
|
|
79
|
-
APIActionRowComponent,
|
|
80
77
|
APITextInputComponent,
|
|
81
|
-
APIModalActionRowComponent,
|
|
82
78
|
APIModalSubmitInteraction,
|
|
79
|
+
Permissions,
|
|
80
|
+
GuildDefaultMessageNotifications,
|
|
81
|
+
GuildExplicitContentFilter,
|
|
82
|
+
GuildMFALevel,
|
|
83
|
+
GuildSystemChannelFlags,
|
|
84
|
+
GuildPremiumTier,
|
|
85
|
+
GuildNSFWLevel,
|
|
86
|
+
GuildHubType,
|
|
87
|
+
GuildVerificationLevel,
|
|
88
|
+
GuildFeature,
|
|
83
89
|
LocalizationMap,
|
|
84
90
|
} from 'discord-api-types/v9';
|
|
85
|
-
import { GuildChannel, Guild, PermissionOverwrites
|
|
86
|
-
|
|
91
|
+
import { GuildChannel, Guild, PermissionOverwrites } from '.';
|
|
87
92
|
import type {
|
|
88
93
|
AutoModerationActionTypes,
|
|
89
94
|
AutoModerationRuleEventTypes,
|
|
90
95
|
AutoModerationRuleKeywordPresetTypes,
|
|
91
96
|
AutoModerationRuleTriggerTypes,
|
|
92
|
-
InteractionTypes,
|
|
93
|
-
MessageComponentTypes,
|
|
94
97
|
ApplicationRoleConnectionMetadataTypes,
|
|
95
98
|
} from './enums';
|
|
96
99
|
|
|
@@ -170,7 +173,20 @@ export type RawInviteStageInstance = APIInviteStageInstance;
|
|
|
170
173
|
export type RawMessageData = APIMessage;
|
|
171
174
|
export type RawPartialMessageData = GatewayMessageUpdateDispatchData;
|
|
172
175
|
|
|
173
|
-
export
|
|
176
|
+
export interface RawMessageAttachmentData {
|
|
177
|
+
id: Snowflake;
|
|
178
|
+
filename: string;
|
|
179
|
+
description?: string;
|
|
180
|
+
content_type?: string;
|
|
181
|
+
size: number;
|
|
182
|
+
url: string;
|
|
183
|
+
proxy_url: string;
|
|
184
|
+
height?: number | null;
|
|
185
|
+
width?: number | null;
|
|
186
|
+
ephemeral?: boolean;
|
|
187
|
+
duration_secs?: number;
|
|
188
|
+
waveform?: string;
|
|
189
|
+
}
|
|
174
190
|
|
|
175
191
|
export type RawMessagePayloadData =
|
|
176
192
|
| RESTPostAPIChannelMessageJSONBody
|
|
@@ -271,6 +287,49 @@ export interface APIAutoModerationRuleTriggerMetadata {
|
|
|
271
287
|
allow_list?: string[];
|
|
272
288
|
regex_patterns?: string[];
|
|
273
289
|
mention_total_limit?: number;
|
|
290
|
+
mention_raid_protection_enabled?: boolean;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface APIGuild extends APIPartialGuild {
|
|
294
|
+
icon_hash?: string | null;
|
|
295
|
+
discovery_splash: string | null;
|
|
296
|
+
owner?: boolean;
|
|
297
|
+
owner_id: Snowflake;
|
|
298
|
+
permissions?: Permissions;
|
|
299
|
+
region: string;
|
|
300
|
+
afk_channel_id: Snowflake | null;
|
|
301
|
+
afk_timeout: number;
|
|
302
|
+
widget_enabled?: boolean;
|
|
303
|
+
widget_channel_id?: Snowflake | null;
|
|
304
|
+
verification_level: GuildVerificationLevel;
|
|
305
|
+
default_message_notifications: GuildDefaultMessageNotifications;
|
|
306
|
+
explicit_content_filter: GuildExplicitContentFilter;
|
|
307
|
+
roles: APIRole[];
|
|
308
|
+
emojis: APIEmoji[];
|
|
309
|
+
features: GuildFeature[];
|
|
310
|
+
mfa_level: GuildMFALevel;
|
|
311
|
+
application_id: Snowflake | null;
|
|
312
|
+
system_channel_id: Snowflake | null;
|
|
313
|
+
system_channel_flags: GuildSystemChannelFlags;
|
|
314
|
+
rules_channel_id: Snowflake | null;
|
|
315
|
+
max_presences?: number | null;
|
|
316
|
+
max_members?: number;
|
|
317
|
+
vanity_url_code: string | null;
|
|
318
|
+
description: string | null;
|
|
319
|
+
banner: string | null;
|
|
320
|
+
premium_tier: GuildPremiumTier;
|
|
321
|
+
premium_subscription_count?: number;
|
|
322
|
+
preferred_locale: string;
|
|
323
|
+
public_updates_channel_id: Snowflake | null;
|
|
324
|
+
max_video_channel_users?: number;
|
|
325
|
+
approximate_member_count?: number;
|
|
326
|
+
approximate_presence_count?: number;
|
|
327
|
+
welcome_screen?: APIGuildWelcomeScreen;
|
|
328
|
+
nsfw_level: GuildNSFWLevel;
|
|
329
|
+
stickers: APISticker[];
|
|
330
|
+
premium_progress_bar_enabled: boolean;
|
|
331
|
+
hub_type: GuildHubType | null;
|
|
332
|
+
safety_alerts_channel_id: Snowflake | null;
|
|
274
333
|
}
|
|
275
334
|
|
|
276
335
|
export interface APIApplicationRoleConnectionMetadata {
|
|
@@ -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
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
-
};
|
|
File without changes
|
|
File without changes
|
|
@@ -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;
|