@velliajs/discord 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client/BaseClient.js +7 -28
- package/src/client/Client.js +116 -283
- package/src/client/WebhookClient.js +17 -59
- package/src/client/actions/Action.js +0 -10
- package/src/client/actions/ActionsManager.js +3 -3
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
- package/src/client/actions/AutoModerationActionExecution.js +1 -6
- package/src/client/actions/AutoModerationRuleCreate.js +1 -6
- package/src/client/actions/AutoModerationRuleDelete.js +1 -6
- package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
- package/src/client/actions/ChannelCreate.js +1 -5
- package/src/client/actions/ChannelDelete.js +1 -5
- package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
- package/src/client/actions/GuildBanAdd.js +1 -5
- package/src/client/actions/GuildBanRemove.js +1 -5
- package/src/client/actions/GuildDelete.js +6 -14
- package/src/client/actions/GuildEmojiCreate.js +1 -5
- package/src/client/actions/GuildEmojiDelete.js +1 -5
- package/src/client/actions/GuildEmojiUpdate.js +1 -6
- package/src/client/actions/GuildEmojisUpdate.js +4 -4
- package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
- package/src/client/actions/GuildMemberRemove.js +1 -5
- package/src/client/actions/GuildMemberUpdate.js +2 -11
- package/src/client/actions/GuildRoleCreate.js +1 -5
- package/src/client/actions/GuildRoleDelete.js +1 -5
- package/src/client/actions/GuildRoleUpdate.js +1 -6
- package/src/client/actions/GuildScheduledEventCreate.js +1 -5
- package/src/client/actions/GuildScheduledEventDelete.js +1 -5
- package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
- package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
- package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
- package/src/client/actions/GuildStickerCreate.js +1 -5
- package/src/client/actions/GuildStickerDelete.js +1 -5
- package/src/client/actions/GuildStickerUpdate.js +1 -6
- package/src/client/actions/GuildStickersUpdate.js +4 -4
- package/src/client/actions/GuildUpdate.js +1 -6
- package/src/client/actions/InteractionCreate.js +3 -7
- package/src/client/actions/InviteCreate.js +1 -7
- package/src/client/actions/InviteDelete.js +1 -7
- package/src/client/actions/MessageCreate.js +1 -5
- package/src/client/actions/MessageDelete.js +1 -5
- package/src/client/actions/MessageDeleteBulk.js +1 -6
- package/src/client/actions/MessageReactionAdd.js +5 -18
- package/src/client/actions/MessageReactionRemove.js +5 -16
- package/src/client/actions/MessageReactionRemoveAll.js +4 -9
- package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
- package/src/client/actions/PresenceUpdate.js +1 -6
- package/src/client/actions/StageInstanceCreate.js +1 -5
- package/src/client/actions/StageInstanceDelete.js +1 -5
- package/src/client/actions/StageInstanceUpdate.js +1 -6
- package/src/client/actions/ThreadCreate.js +1 -6
- package/src/client/actions/ThreadDelete.js +1 -5
- package/src/client/actions/ThreadListSync.js +2 -7
- package/src/client/actions/ThreadMemberUpdate.js +2 -7
- package/src/client/actions/ThreadMembersUpdate.js +2 -9
- package/src/client/actions/TypingStart.js +1 -5
- package/src/client/actions/UserUpdate.js +1 -8
- package/src/client/actions/VoiceStateUpdate.js +4 -9
- package/src/client/actions/WebhooksUpdate.js +1 -6
- package/src/client/voice/ClientVoiceManager.js +3 -13
- package/src/client/websocket/WebSocketManager.js +25 -117
- package/src/client/websocket/WebSocketShard.js +29 -116
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
- package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
- package/src/client/websocket/handlers/RESUMED.js +1 -6
- package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
- package/src/errors/DJSError.js +3 -14
- package/src/errors/ErrorCodes.js +2 -164
- package/src/index.js +6 -6
- package/src/managers/ApplicationCommandManager.js +14 -130
- package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
- package/src/managers/AutoModerationRuleManager.js +17 -145
- package/src/managers/BaseGuildEmojiManager.js +7 -38
- package/src/managers/BaseManager.js +2 -10
- package/src/managers/CachedManager.js +3 -17
- package/src/managers/CategoryChannelChildManager.js +6 -48
- package/src/managers/ChannelManager.js +11 -52
- package/src/managers/DataManager.js +5 -27
- package/src/managers/GuildApplicationCommandManager.js +3 -12
- package/src/managers/GuildBanManager.js +16 -105
- package/src/managers/GuildChannelManager.js +31 -226
- package/src/managers/GuildEmojiManager.js +9 -65
- package/src/managers/GuildEmojiRoleManager.js +8 -47
- package/src/managers/GuildForumThreadManager.js +5 -39
- package/src/managers/GuildInviteManager.js +18 -117
- package/src/managers/GuildManager.js +14 -115
- package/src/managers/GuildMemberManager.js +38 -256
- package/src/managers/GuildMemberRoleManager.js +13 -76
- package/src/managers/GuildScheduledEventManager.js +25 -128
- package/src/managers/GuildStickerManager.js +16 -96
- package/src/managers/GuildTextThreadManager.js +4 -47
- package/src/managers/MessageManager.js +23 -137
- package/src/managers/PermissionOverwriteManager.js +10 -78
- package/src/managers/PresenceManager.js +6 -27
- package/src/managers/ReactionManager.js +7 -40
- package/src/managers/ReactionUserManager.js +6 -29
- package/src/managers/RoleManager.js +29 -177
- package/src/managers/StageInstanceManager.js +14 -77
- package/src/managers/ThreadManager.js +23 -113
- package/src/managers/ThreadMemberManager.js +20 -89
- package/src/managers/UserManager.js +13 -65
- package/src/managers/VoiceStateManager.js +3 -13
- package/src/sharding/Shard.js +42 -158
- package/src/sharding/ShardClientUtil.js +17 -101
- package/src/sharding/ShardingManager.js +34 -151
- package/src/structures/ActionRow.js +4 -21
- package/src/structures/ActionRowBuilder.js +3 -13
- package/src/structures/AnonymousGuild.js +10 -43
- package/src/structures/ApplicationCommand.js +54 -308
- package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
- package/src/structures/Attachment.js +16 -65
- package/src/structures/AttachmentBuilder.js +13 -58
- package/src/structures/AutoModerationActionExecution.js +16 -69
- package/src/structures/AutoModerationRule.js +32 -164
- package/src/structures/AutocompleteInteraction.js +10 -52
- package/src/structures/Base.js +2 -10
- package/src/structures/BaseChannel.js +16 -80
- package/src/structures/BaseGuild.js +13 -59
- package/src/structures/BaseGuildEmoji.js +5 -21
- package/src/structures/BaseGuildTextChannel.js +19 -100
- package/src/structures/BaseGuildVoiceChannel.js +21 -110
- package/src/structures/BaseInteraction.js +40 -196
- package/src/structures/BaseSelectMenuComponent.js +6 -29
- package/src/structures/ButtonBuilder.js +4 -18
- package/src/structures/ButtonComponent.js +7 -34
- package/src/structures/ButtonInteraction.js +1 -4
- package/src/structures/CategoryChannel.js +5 -30
- package/src/structures/ChannelSelectMenuBuilder.js +3 -13
- package/src/structures/ChannelSelectMenuComponent.js +2 -9
- package/src/structures/ChannelSelectMenuInteraction.js +3 -12
- package/src/structures/ChatInputCommandInteraction.js +3 -13
- package/src/structures/ClientApplication.js +20 -83
- package/src/structures/ClientPresence.js +5 -20
- package/src/structures/ClientUser.js +21 -118
- package/src/structures/CommandInteraction.js +21 -96
- package/src/structures/CommandInteractionOptionResolver.js +26 -147
- package/src/structures/Component.js +5 -21
- package/src/structures/ContextMenuCommandInteraction.js +4 -18
- package/src/structures/DMChannel.js +17 -52
- package/src/structures/DirectoryChannel.js +4 -16
- package/src/structures/Embed.js +21 -107
- package/src/structures/EmbedBuilder.js +4 -18
- package/src/structures/Emoji.js +12 -60
- package/src/structures/ForumChannel.js +30 -140
- package/src/structures/Guild.js +117 -697
- package/src/structures/GuildAuditLogs.js +7 -32
- package/src/structures/GuildAuditLogsEntry.js +27 -135
- package/src/structures/GuildBan.js +6 -26
- package/src/structures/GuildChannel.js +36 -188
- package/src/structures/GuildEmoji.js +13 -67
- package/src/structures/GuildMember.js +47 -270
- package/src/structures/GuildPreview.js +19 -84
- package/src/structures/GuildPreviewEmoji.js +3 -13
- package/src/structures/GuildScheduledEvent.js +46 -250
- package/src/structures/GuildTemplate.js +24 -108
- package/src/structures/Integration.js +25 -103
- package/src/structures/IntegrationApplication.js +8 -32
- package/src/structures/InteractionCollector.js +22 -113
- package/src/structures/InteractionResponse.js +11 -46
- package/src/structures/InteractionWebhook.js +8 -33
- package/src/structures/Invite.js +27 -131
- package/src/structures/InviteGuild.js +2 -8
- package/src/structures/InviteStageInstance.js +9 -39
- package/src/structures/MentionableSelectMenuBuilder.js +3 -14
- package/src/structures/MentionableSelectMenuComponent.js +1 -4
- package/src/structures/MentionableSelectMenuInteraction.js +5 -20
- package/src/structures/Message.js +85 -460
- package/src/structures/MessageCollector.js +14 -70
- package/src/structures/MessageComponentInteraction.js +14 -57
- package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
- package/src/structures/MessageMentions.js +25 -136
- package/src/structures/MessagePayload.js +24 -94
- package/src/structures/MessageReaction.js +13 -51
- package/src/structures/ModalBuilder.js +3 -13
- package/src/structures/ModalSubmitFields.js +5 -22
- package/src/structures/ModalSubmitInteraction.js +17 -61
- package/src/structures/NewsChannel.js +2 -16
- package/src/structures/OAuth2Guild.js +3 -12
- package/src/structures/PartialGroupDMChannel.js +7 -27
- package/src/structures/PermissionOverwrites.js +20 -99
- package/src/structures/Presence.js +45 -190
- package/src/structures/ReactionCollector.js +20 -108
- package/src/structures/ReactionEmoji.js +2 -10
- package/src/structures/Role.js +39 -261
- package/src/structures/RoleSelectMenuBuilder.js +3 -13
- package/src/structures/RoleSelectMenuComponent.js +1 -4
- package/src/structures/RoleSelectMenuInteraction.js +3 -12
- package/src/structures/SelectMenuBuilder.js +1 -4
- package/src/structures/SelectMenuComponent.js +1 -4
- package/src/structures/SelectMenuInteraction.js +1 -4
- package/src/structures/SelectMenuOptionBuilder.js +1 -4
- package/src/structures/StageChannel.js +12 -84
- package/src/structures/StageInstance.js +16 -87
- package/src/structures/Sticker.js +25 -124
- package/src/structures/StickerPack.js +12 -52
- package/src/structures/StringSelectMenuBuilder.js +6 -29
- package/src/structures/StringSelectMenuComponent.js +2 -9
- package/src/structures/StringSelectMenuInteraction.js +2 -8
- package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
- package/src/structures/Team.js +11 -52
- package/src/structures/TeamMember.js +7 -33
- package/src/structures/TextChannel.js +3 -14
- package/src/structures/TextInputBuilder.js +3 -13
- package/src/structures/TextInputComponent.js +3 -14
- package/src/structures/ThreadChannel.js +59 -305
- package/src/structures/ThreadMember.js +12 -55
- package/src/structures/Typing.js +8 -35
- package/src/structures/User.js +29 -151
- package/src/structures/UserContextMenuCommandInteraction.js +3 -14
- package/src/structures/UserSelectMenuBuilder.js +3 -13
- package/src/structures/UserSelectMenuComponent.js +1 -4
- package/src/structures/UserSelectMenuInteraction.js +4 -16
- package/src/structures/VoiceChannel.js +8 -67
- package/src/structures/VoiceRegion.js +6 -23
- package/src/structures/VoiceState.js +28 -140
- package/src/structures/Webhook.js +37 -227
- package/src/structures/WelcomeChannel.js +7 -29
- package/src/structures/WelcomeScreen.js +5 -20
- package/src/structures/Widget.js +9 -40
- package/src/structures/WidgetMember.js +15 -61
- package/src/structures/interfaces/Application.js +10 -49
- package/src/structures/interfaces/Collector.js +34 -155
- package/src/structures/interfaces/InteractionResponses.js +25 -164
- package/src/structures/interfaces/TextBasedChannel.js +37 -232
- package/src/util/APITypes.js +183 -456
- package/src/util/ActivityFlagsBitField.js +3 -15
- package/src/util/ApplicationFlagsBitField.js +3 -15
- package/src/util/BitField.js +17 -82
- package/src/util/ChannelFlagsBitField.js +7 -30
- package/src/util/Channels.js +5 -35
- package/src/util/Colors.js +3 -38
- package/src/util/Components.js +21 -75
- package/src/util/Constants.js +17 -144
- package/src/util/DataResolver.js +20 -77
- package/src/util/Events.js +3 -81
- package/src/util/Formatters.js +58 -305
- package/src/util/GuildMemberFlagsBitField.js +7 -30
- package/src/util/IntentsBitField.js +4 -23
- package/src/util/LimitedCollection.js +4 -21
- package/src/util/MessageFlagsBitField.js +5 -21
- package/src/util/Options.js +24 -137
- package/src/util/Partials.js +3 -30
- package/src/util/PermissionsBitField.js +12 -67
- package/src/util/ShardEvents.js +3 -15
- package/src/util/Status.js +3 -17
- package/src/util/Sweepers.js +35 -184
- package/src/util/SystemChannelFlagsBitField.js +7 -32
- package/src/util/ThreadMemberFlagsBitField.js +5 -21
- package/src/util/Transformers.js +2 -11
- package/src/util/UserFlagsBitField.js +5 -21
- package/src/util/Util.js +30 -169
- package/src/util/WebSocketShardEvents.js +3 -14
|
@@ -4,64 +4,28 @@ const { Collection } = require('@discordjs/collection');
|
|
|
4
4
|
const Collector = require('./interfaces/Collector');
|
|
5
5
|
const Events = require('../util/Events');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @property {ComponentType} [componentType] The type of component to listen for
|
|
11
|
-
* @property {GuildResolvable} [guild] The guild to listen to interactions from
|
|
12
|
-
* @property {InteractionType} [interactionType] The type of interaction to listen for
|
|
13
|
-
* @property {number} [max] The maximum total amount of interactions to collect
|
|
14
|
-
* @property {number} [maxComponents] The maximum number of components to collect
|
|
15
|
-
* @property {number} [maxUsers] The maximum number of users to interact
|
|
16
|
-
* @property {Message|APIMessage} [message] The message to listen to interactions from
|
|
17
|
-
* @property {InteractionResponse} [interactionResponse] The interaction response to listen
|
|
18
|
-
* to message component interactions from
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Collects interactions.
|
|
23
|
-
* Will automatically stop if the message ({@link Client#event:messageDelete messageDelete} or
|
|
24
|
-
* {@link Client#event:messageDeleteBulk messageDeleteBulk}),
|
|
25
|
-
* channel ({@link Client#event:channelDelete channelDelete}), or
|
|
26
|
-
* guild ({@link Client#event:guildDelete guildDelete}) is deleted.
|
|
27
|
-
* <info>Interaction collectors that do not specify `time` or `idle` may be prone to always running.
|
|
28
|
-
* Ensure your interaction collectors end via either of these options or manual cancellation.</info>
|
|
29
|
-
* @extends {Collector}
|
|
30
|
-
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
31
10
|
class InteractionCollector extends Collector {
|
|
32
|
-
|
|
33
|
-
* @param {Client} client The client on which to collect interactions
|
|
34
|
-
* @param {InteractionCollectorOptions} [options={}] The options to apply to this collector
|
|
35
|
-
*/
|
|
11
|
+
|
|
36
12
|
constructor(client, options = {}) {
|
|
37
13
|
super(client, options);
|
|
38
14
|
|
|
39
|
-
|
|
40
|
-
* The message from which to collect interactions, if provided
|
|
41
|
-
* @type {?Snowflake}
|
|
42
|
-
*/
|
|
15
|
+
|
|
43
16
|
this.messageId = options.message?.id ?? null;
|
|
44
17
|
|
|
45
|
-
|
|
46
|
-
* The message interaction id from which to collect interactions, if provided
|
|
47
|
-
* @type {?Snowflake}
|
|
48
|
-
*/
|
|
18
|
+
|
|
49
19
|
this.messageInteractionId = options.interactionResponse?.id ?? null;
|
|
50
20
|
|
|
51
|
-
|
|
52
|
-
* The channel from which to collect interactions, if provided
|
|
53
|
-
* @type {?Snowflake}
|
|
54
|
-
*/
|
|
21
|
+
|
|
55
22
|
this.channelId =
|
|
56
23
|
options.interactionResponse?.interaction.channelId ??
|
|
57
24
|
options.message?.channelId ??
|
|
58
25
|
options.message?.channel_id ??
|
|
59
26
|
this.client.channels.resolveId(options.channel);
|
|
60
27
|
|
|
61
|
-
|
|
62
|
-
* The guild from which to collect interactions, if provided
|
|
63
|
-
* @type {?Snowflake}
|
|
64
|
-
*/
|
|
28
|
+
|
|
65
29
|
this.guildId =
|
|
66
30
|
options.interactionResponse?.interaction.guildId ??
|
|
67
31
|
options.message?.guildId ??
|
|
@@ -69,28 +33,16 @@ class InteractionCollector extends Collector {
|
|
|
69
33
|
this.client.guilds.resolveId(options.channel?.guild) ??
|
|
70
34
|
this.client.guilds.resolveId(options.guild);
|
|
71
35
|
|
|
72
|
-
|
|
73
|
-
* The type of interaction to collect
|
|
74
|
-
* @type {?InteractionType}
|
|
75
|
-
*/
|
|
36
|
+
|
|
76
37
|
this.interactionType = options.interactionType ?? null;
|
|
77
38
|
|
|
78
|
-
|
|
79
|
-
* The type of component to collect
|
|
80
|
-
* @type {?ComponentType}
|
|
81
|
-
*/
|
|
39
|
+
|
|
82
40
|
this.componentType = options.componentType ?? null;
|
|
83
41
|
|
|
84
|
-
|
|
85
|
-
* The users that have interacted with this collector
|
|
86
|
-
* @type {Collection<Snowflake, User>}
|
|
87
|
-
*/
|
|
42
|
+
|
|
88
43
|
this.users = new Collection();
|
|
89
44
|
|
|
90
|
-
|
|
91
|
-
* The total number of interactions collected
|
|
92
|
-
* @type {number}
|
|
93
|
-
*/
|
|
45
|
+
|
|
94
46
|
this.total = 0;
|
|
95
47
|
|
|
96
48
|
this.client.incrementMaxListeners();
|
|
@@ -135,18 +87,9 @@ class InteractionCollector extends Collector {
|
|
|
135
87
|
});
|
|
136
88
|
}
|
|
137
89
|
|
|
138
|
-
|
|
139
|
-
* Handles an incoming interaction for possible collection.
|
|
140
|
-
* @param {BaseInteraction} interaction The interaction to possibly collect
|
|
141
|
-
* @returns {?Snowflake}
|
|
142
|
-
* @private
|
|
143
|
-
*/
|
|
90
|
+
|
|
144
91
|
collect(interaction) {
|
|
145
|
-
|
|
146
|
-
* Emitted whenever an interaction is collected.
|
|
147
|
-
* @event InteractionCollector#collect
|
|
148
|
-
* @param {BaseInteraction} interaction The interaction that was collected
|
|
149
|
-
*/
|
|
92
|
+
|
|
150
93
|
|
|
151
94
|
if (this.interactionType && interaction.type !== this.interactionType) return null;
|
|
152
95
|
if (this.componentType && interaction.componentType !== this.componentType) return null;
|
|
@@ -164,17 +107,9 @@ class InteractionCollector extends Collector {
|
|
|
164
107
|
return interaction.id;
|
|
165
108
|
}
|
|
166
109
|
|
|
167
|
-
|
|
168
|
-
* Handles an interaction for possible disposal.
|
|
169
|
-
* @param {BaseInteraction} interaction The interaction that could be disposed of
|
|
170
|
-
* @returns {?Snowflake}
|
|
171
|
-
*/
|
|
110
|
+
|
|
172
111
|
dispose(interaction) {
|
|
173
|
-
|
|
174
|
-
* Emitted whenever an interaction is disposed of.
|
|
175
|
-
* @event InteractionCollector#dispose
|
|
176
|
-
* @param {BaseInteraction} interaction The interaction that was disposed of
|
|
177
|
-
*/
|
|
112
|
+
|
|
178
113
|
if (this.type && interaction.type !== this.type) return null;
|
|
179
114
|
if (this.componentType && interaction.componentType !== this.componentType) return null;
|
|
180
115
|
if (this.messageId && interaction.message?.id !== this.messageId) return null;
|
|
@@ -185,9 +120,7 @@ class InteractionCollector extends Collector {
|
|
|
185
120
|
return interaction.id;
|
|
186
121
|
}
|
|
187
122
|
|
|
188
|
-
|
|
189
|
-
* Empties this interaction collector.
|
|
190
|
-
*/
|
|
123
|
+
|
|
191
124
|
empty() {
|
|
192
125
|
this.total = 0;
|
|
193
126
|
this.collected.clear();
|
|
@@ -195,11 +128,7 @@ class InteractionCollector extends Collector {
|
|
|
195
128
|
this.checkEnd();
|
|
196
129
|
}
|
|
197
130
|
|
|
198
|
-
|
|
199
|
-
* The reason this collector has ended with, or null if it hasn't ended yet
|
|
200
|
-
* @type {?string}
|
|
201
|
-
* @readonly
|
|
202
|
-
*/
|
|
131
|
+
|
|
203
132
|
get endReason() {
|
|
204
133
|
if (this.options.max && this.total >= this.options.max) return 'limit';
|
|
205
134
|
if (this.options.maxComponents && this.collected.size >= this.options.maxComponents) return 'componentLimit';
|
|
@@ -207,12 +136,7 @@ class InteractionCollector extends Collector {
|
|
|
207
136
|
return super.endReason;
|
|
208
137
|
}
|
|
209
138
|
|
|
210
|
-
|
|
211
|
-
* Handles checking if the message has been deleted, and if so, stops the collector with the reason 'messageDelete'.
|
|
212
|
-
* @private
|
|
213
|
-
* @param {Message} message The message that was deleted
|
|
214
|
-
* @returns {void}
|
|
215
|
-
*/
|
|
139
|
+
|
|
216
140
|
_handleMessageDeletion(message) {
|
|
217
141
|
if (message.id === this.messageId) {
|
|
218
142
|
this.stop('messageDelete');
|
|
@@ -223,36 +147,21 @@ class InteractionCollector extends Collector {
|
|
|
223
147
|
}
|
|
224
148
|
}
|
|
225
149
|
|
|
226
|
-
|
|
227
|
-
* Handles checking if the channel has been deleted, and if so, stops the collector with the reason 'channelDelete'.
|
|
228
|
-
* @private
|
|
229
|
-
* @param {GuildChannel} channel The channel that was deleted
|
|
230
|
-
* @returns {void}
|
|
231
|
-
*/
|
|
150
|
+
|
|
232
151
|
_handleChannelDeletion(channel) {
|
|
233
152
|
if (channel.id === this.channelId || channel.threads?.cache.has(this.channelId)) {
|
|
234
153
|
this.stop('channelDelete');
|
|
235
154
|
}
|
|
236
155
|
}
|
|
237
156
|
|
|
238
|
-
|
|
239
|
-
* Handles checking if the thread has been deleted, and if so, stops the collector with the reason 'threadDelete'.
|
|
240
|
-
* @private
|
|
241
|
-
* @param {ThreadChannel} thread The thread that was deleted
|
|
242
|
-
* @returns {void}
|
|
243
|
-
*/
|
|
157
|
+
|
|
244
158
|
_handleThreadDeletion(thread) {
|
|
245
159
|
if (thread.id === this.channelId) {
|
|
246
160
|
this.stop('threadDelete');
|
|
247
161
|
}
|
|
248
162
|
}
|
|
249
163
|
|
|
250
|
-
|
|
251
|
-
* Handles checking if the guild has been deleted, and if so, stops the collector with the reason 'guildDelete'.
|
|
252
|
-
* @private
|
|
253
|
-
* @param {Guild} guild The guild that was deleted
|
|
254
|
-
* @returns {void}
|
|
255
|
-
*/
|
|
164
|
+
|
|
256
165
|
_handleGuildDeletion(guild) {
|
|
257
166
|
if (guild.id === this.guildId) {
|
|
258
167
|
this.stop('guildDelete');
|
|
@@ -4,48 +4,27 @@ const { DiscordSnowflake } = require('@sapphire/snowflake');
|
|
|
4
4
|
const { InteractionType } = require('discord-api-types/v10');
|
|
5
5
|
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Represents an interaction's response
|
|
9
|
-
*/
|
|
7
|
+
|
|
10
8
|
class InteractionResponse {
|
|
11
9
|
constructor(interaction, id) {
|
|
12
|
-
|
|
13
|
-
* The interaction associated with the interaction response
|
|
14
|
-
* @type {BaseInteraction}
|
|
15
|
-
*/
|
|
10
|
+
|
|
16
11
|
this.interaction = interaction;
|
|
17
|
-
|
|
18
|
-
* The id of the original interaction response
|
|
19
|
-
* @type {Snowflake}
|
|
20
|
-
*/
|
|
12
|
+
|
|
21
13
|
this.id = id ?? interaction.id;
|
|
22
14
|
this.client = interaction.client;
|
|
23
15
|
}
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
* The timestamp the interaction response was created at
|
|
27
|
-
* @type {number}
|
|
28
|
-
* @readonly
|
|
29
|
-
*/
|
|
17
|
+
|
|
30
18
|
get createdTimestamp() {
|
|
31
19
|
return DiscordSnowflake.timestampFrom(this.id);
|
|
32
20
|
}
|
|
33
21
|
|
|
34
|
-
|
|
35
|
-
* The time the interaction response was created at
|
|
36
|
-
* @type {Date}
|
|
37
|
-
* @readonly
|
|
38
|
-
*/
|
|
22
|
+
|
|
39
23
|
get createdAt() {
|
|
40
24
|
return new Date(this.createdTimestamp);
|
|
41
25
|
}
|
|
42
26
|
|
|
43
|
-
|
|
44
|
-
* Collects a single component interaction that passes the filter.
|
|
45
|
-
* The Promise will reject if the time expires.
|
|
46
|
-
* @param {AwaitMessageComponentOptions} [options={}] Options to pass to the internal collector
|
|
47
|
-
* @returns {Promise<MessageComponentInteraction>}
|
|
48
|
-
*/
|
|
27
|
+
|
|
49
28
|
awaitMessageComponent(options = {}) {
|
|
50
29
|
const _options = { ...options, max: 1 };
|
|
51
30
|
return new Promise((resolve, reject) => {
|
|
@@ -58,11 +37,7 @@ class InteractionResponse {
|
|
|
58
37
|
});
|
|
59
38
|
}
|
|
60
39
|
|
|
61
|
-
|
|
62
|
-
* Creates a message component interaction collector
|
|
63
|
-
* @param {MessageComponentCollectorOptions} [options={}] Options to send to the collector
|
|
64
|
-
* @returns {InteractionCollector}
|
|
65
|
-
*/
|
|
40
|
+
|
|
66
41
|
createMessageComponentCollector(options = {}) {
|
|
67
42
|
return new InteractionCollector(this.client, {
|
|
68
43
|
...options,
|
|
@@ -71,32 +46,22 @@ class InteractionResponse {
|
|
|
71
46
|
});
|
|
72
47
|
}
|
|
73
48
|
|
|
74
|
-
|
|
75
|
-
* Fetches the response as a {@link Message} object.
|
|
76
|
-
* @returns {Promise<Message>}
|
|
77
|
-
*/
|
|
49
|
+
|
|
78
50
|
fetch() {
|
|
79
51
|
return this.interaction.fetchReply();
|
|
80
52
|
}
|
|
81
53
|
|
|
82
|
-
|
|
83
|
-
* Deletes the response.
|
|
84
|
-
* @returns {Promise<void>}
|
|
85
|
-
*/
|
|
54
|
+
|
|
86
55
|
delete() {
|
|
87
56
|
return this.interaction.deleteReply();
|
|
88
57
|
}
|
|
89
58
|
|
|
90
|
-
|
|
91
|
-
* Edits the response.
|
|
92
|
-
* @param {string|MessagePayload|WebhookMessageEditOptions} options The new options for the response.
|
|
93
|
-
* @returns {Promise<Message>}
|
|
94
|
-
*/
|
|
59
|
+
|
|
95
60
|
edit(options) {
|
|
96
61
|
return this.interaction.editReply(options);
|
|
97
62
|
}
|
|
98
63
|
}
|
|
99
64
|
|
|
100
|
-
|
|
65
|
+
|
|
101
66
|
const InteractionCollector = require('./InteractionCollector');
|
|
102
67
|
module.exports = InteractionResponse;
|
|
@@ -2,52 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
const Webhook = require('./Webhook');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* Represents a webhook for an Interaction
|
|
7
|
-
* @implements {Webhook}
|
|
8
|
-
*/
|
|
5
|
+
|
|
9
6
|
class InteractionWebhook {
|
|
10
|
-
|
|
11
|
-
* @param {Client} client The instantiating client
|
|
12
|
-
* @param {Snowflake} id The application's id
|
|
13
|
-
* @param {string} token The interaction's token
|
|
14
|
-
*/
|
|
7
|
+
|
|
15
8
|
constructor(client, id, token) {
|
|
16
|
-
|
|
17
|
-
* The client that instantiated the interaction webhook
|
|
18
|
-
* @name InteractionWebhook#client
|
|
19
|
-
* @type {Client}
|
|
20
|
-
* @readonly
|
|
21
|
-
*/
|
|
9
|
+
|
|
22
10
|
Object.defineProperty(this, 'client', { value: client });
|
|
23
11
|
this.id = id;
|
|
24
12
|
Object.defineProperty(this, 'token', { value: token, writable: true, configurable: true });
|
|
25
13
|
}
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* Sends a message with this webhook.
|
|
31
|
-
* @param {string|MessagePayload|InteractionReplyOptions} options The content for the reply
|
|
32
|
-
* @returns {Promise<Message>}
|
|
33
|
-
*/
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
34
18
|
|
|
35
19
|
send() {}
|
|
36
20
|
|
|
37
|
-
|
|
38
|
-
* Gets a message that was sent by this webhook.
|
|
39
|
-
* @param {Snowflake|'@original'} message The id of the message to fetch
|
|
40
|
-
* @returns {Promise<Message>} Returns the message sent by this webhook
|
|
41
|
-
*/
|
|
21
|
+
|
|
42
22
|
|
|
43
23
|
fetchMessage() {}
|
|
44
24
|
|
|
45
|
-
|
|
46
|
-
* Edits a message that was sent by this webhook.
|
|
47
|
-
* @param {MessageResolvable|'@original'} message The message to edit
|
|
48
|
-
* @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide
|
|
49
|
-
* @returns {Promise<Message>} Returns the message edited by this webhook
|
|
50
|
-
*/
|
|
25
|
+
|
|
51
26
|
|
|
52
27
|
editMessage() {}
|
|
53
28
|
deleteMessage() {}
|
package/src/structures/Invite.js
CHANGED
|
@@ -7,17 +7,9 @@ const IntegrationApplication = require('./IntegrationApplication');
|
|
|
7
7
|
const InviteStageInstance = require('./InviteStageInstance');
|
|
8
8
|
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
* Represents an invitation to a guild channel.
|
|
12
|
-
* @extends {Base}
|
|
13
|
-
*/
|
|
10
|
+
|
|
14
11
|
class Invite extends Base {
|
|
15
|
-
|
|
16
|
-
* A regular expression that matches Discord invite links.
|
|
17
|
-
* The `code` group property is present on the `exec()` result of this expression.
|
|
18
|
-
* @type {RegExp}
|
|
19
|
-
* @memberof Invite
|
|
20
|
-
*/
|
|
12
|
+
|
|
21
13
|
static InvitesPattern = /discord(?:(?:app)?\.com\/invite|\.gg(?:\/invite)?)\/(?<code>[\w-]{2,255})/i;
|
|
22
14
|
|
|
23
15
|
constructor(client, data) {
|
|
@@ -27,98 +19,61 @@ class Invite extends Base {
|
|
|
27
19
|
|
|
28
20
|
_patch(data) {
|
|
29
21
|
const InviteGuild = require('./InviteGuild');
|
|
30
|
-
|
|
31
|
-
* The guild the invite is for including welcome screen data if present
|
|
32
|
-
* @type {?(Guild|InviteGuild)}
|
|
33
|
-
*/
|
|
22
|
+
|
|
34
23
|
this.guild ??= null;
|
|
35
24
|
if (data.guild) {
|
|
36
25
|
this.guild = this.client.guilds.resolve(data.guild.id) ?? new InviteGuild(this.client, data.guild);
|
|
37
26
|
}
|
|
38
27
|
|
|
39
28
|
if ('code' in data) {
|
|
40
|
-
|
|
41
|
-
* The code for this invite
|
|
42
|
-
* @type {string}
|
|
43
|
-
*/
|
|
29
|
+
|
|
44
30
|
this.code = data.code;
|
|
45
31
|
}
|
|
46
32
|
|
|
47
33
|
if ('approximate_presence_count' in data) {
|
|
48
|
-
|
|
49
|
-
* The approximate number of online members of the guild this invite is for
|
|
50
|
-
* <info>This is only available when the invite was fetched through {@link Client#fetchInvite}.</info>
|
|
51
|
-
* @type {?number}
|
|
52
|
-
*/
|
|
34
|
+
|
|
53
35
|
this.presenceCount = data.approximate_presence_count;
|
|
54
36
|
} else {
|
|
55
37
|
this.presenceCount ??= null;
|
|
56
38
|
}
|
|
57
39
|
|
|
58
40
|
if ('approximate_member_count' in data) {
|
|
59
|
-
|
|
60
|
-
* The approximate total number of members of the guild this invite is for
|
|
61
|
-
* <info>This is only available when the invite was fetched through {@link Client#fetchInvite}.</info>
|
|
62
|
-
* @type {?number}
|
|
63
|
-
*/
|
|
41
|
+
|
|
64
42
|
this.memberCount = data.approximate_member_count;
|
|
65
43
|
} else {
|
|
66
44
|
this.memberCount ??= null;
|
|
67
45
|
}
|
|
68
46
|
|
|
69
47
|
if ('temporary' in data) {
|
|
70
|
-
|
|
71
|
-
* Whether or not this invite only grants temporary membership
|
|
72
|
-
* <info>This is only available when the invite was fetched through {@link GuildInviteManager#fetch}
|
|
73
|
-
* or created through {@link GuildInviteManager#create}.</info>
|
|
74
|
-
* @type {?boolean}
|
|
75
|
-
*/
|
|
48
|
+
|
|
76
49
|
this.temporary = data.temporary ?? null;
|
|
77
50
|
} else {
|
|
78
51
|
this.temporary ??= null;
|
|
79
52
|
}
|
|
80
53
|
|
|
81
54
|
if ('max_age' in data) {
|
|
82
|
-
|
|
83
|
-
* The maximum age of the invite, in seconds, 0 if never expires
|
|
84
|
-
* <info>This is only available when the invite was fetched through {@link GuildInviteManager#fetch}
|
|
85
|
-
* or created through {@link GuildInviteManager#create}.</info>
|
|
86
|
-
* @type {?number}
|
|
87
|
-
*/
|
|
55
|
+
|
|
88
56
|
this.maxAge = data.max_age;
|
|
89
57
|
} else {
|
|
90
58
|
this.maxAge ??= null;
|
|
91
59
|
}
|
|
92
60
|
|
|
93
61
|
if ('uses' in data) {
|
|
94
|
-
|
|
95
|
-
* How many times this invite has been used
|
|
96
|
-
* <info>This is only available when the invite was fetched through {@link GuildInviteManager#fetch}
|
|
97
|
-
* or created through {@link GuildInviteManager#create}.</info>
|
|
98
|
-
* @type {?number}
|
|
99
|
-
*/
|
|
62
|
+
|
|
100
63
|
this.uses = data.uses;
|
|
101
64
|
} else {
|
|
102
65
|
this.uses ??= null;
|
|
103
66
|
}
|
|
104
67
|
|
|
105
68
|
if ('max_uses' in data) {
|
|
106
|
-
|
|
107
|
-
* The maximum uses of this invite
|
|
108
|
-
* <info>This is only available when the invite was fetched through {@link GuildInviteManager#fetch}
|
|
109
|
-
* or created through {@link GuildInviteManager#create}.</info>
|
|
110
|
-
* @type {?number}
|
|
111
|
-
*/
|
|
69
|
+
|
|
112
70
|
this.maxUses = data.max_uses;
|
|
113
71
|
} else {
|
|
114
72
|
this.maxUses ??= null;
|
|
115
73
|
}
|
|
116
74
|
|
|
117
75
|
if ('inviter_id' in data) {
|
|
118
|
-
|
|
119
|
-
* The user's id who created this invite
|
|
120
|
-
* @type {?Snowflake}
|
|
121
|
-
*/
|
|
76
|
+
|
|
122
77
|
this.inviterId = data.inviter_id;
|
|
123
78
|
} else {
|
|
124
79
|
this.inviterId ??= null;
|
|
@@ -130,48 +85,33 @@ class Invite extends Base {
|
|
|
130
85
|
}
|
|
131
86
|
|
|
132
87
|
if ('target_user' in data) {
|
|
133
|
-
|
|
134
|
-
* The user whose stream to display for this voice channel stream invite
|
|
135
|
-
* @type {?User}
|
|
136
|
-
*/
|
|
88
|
+
|
|
137
89
|
this.targetUser = this.client.users._add(data.target_user);
|
|
138
90
|
} else {
|
|
139
91
|
this.targetUser ??= null;
|
|
140
92
|
}
|
|
141
93
|
|
|
142
94
|
if ('target_application' in data) {
|
|
143
|
-
|
|
144
|
-
* The embedded application to open for this voice channel embedded application invite
|
|
145
|
-
* @type {?IntegrationApplication}
|
|
146
|
-
*/
|
|
95
|
+
|
|
147
96
|
this.targetApplication = new IntegrationApplication(this.client, data.target_application);
|
|
148
97
|
} else {
|
|
149
98
|
this.targetApplication ??= null;
|
|
150
99
|
}
|
|
151
100
|
|
|
152
101
|
if ('target_type' in data) {
|
|
153
|
-
|
|
154
|
-
* The target type
|
|
155
|
-
* @type {?InviteTargetType}
|
|
156
|
-
*/
|
|
102
|
+
|
|
157
103
|
this.targetType = data.target_type;
|
|
158
104
|
} else {
|
|
159
105
|
this.targetType ??= null;
|
|
160
106
|
}
|
|
161
107
|
|
|
162
108
|
if ('channel_id' in data) {
|
|
163
|
-
|
|
164
|
-
* The id of the channel this invite is for
|
|
165
|
-
* @type {?Snowflake}
|
|
166
|
-
*/
|
|
109
|
+
|
|
167
110
|
this.channelId = data.channel_id;
|
|
168
111
|
}
|
|
169
112
|
|
|
170
113
|
if ('channel' in data) {
|
|
171
|
-
|
|
172
|
-
* The channel this invite is for
|
|
173
|
-
* @type {?BaseChannel}
|
|
174
|
-
*/
|
|
114
|
+
|
|
175
115
|
this.channel =
|
|
176
116
|
this.client.channels._add(data.channel, this.guild, { cache: false }) ??
|
|
177
117
|
this.client.channels.resolve(this.channelId);
|
|
@@ -180,10 +120,7 @@ class Invite extends Base {
|
|
|
180
120
|
}
|
|
181
121
|
|
|
182
122
|
if ('created_at' in data) {
|
|
183
|
-
|
|
184
|
-
* The timestamp this invite was created at
|
|
185
|
-
* @type {?number}
|
|
186
|
-
*/
|
|
123
|
+
|
|
187
124
|
this.createdTimestamp = Date.parse(data.created_at);
|
|
188
125
|
} else {
|
|
189
126
|
this.createdTimestamp ??= null;
|
|
@@ -196,41 +133,26 @@ class Invite extends Base {
|
|
|
196
133
|
}
|
|
197
134
|
|
|
198
135
|
if ('stage_instance' in data) {
|
|
199
|
-
|
|
200
|
-
* The stage instance data if there is a public {@link StageInstance} in the stage channel this invite is for
|
|
201
|
-
* @type {?InviteStageInstance}
|
|
202
|
-
* @deprecated
|
|
203
|
-
*/
|
|
136
|
+
|
|
204
137
|
this.stageInstance = new InviteStageInstance(this.client, data.stage_instance, this.channel.id, this.guild.id);
|
|
205
138
|
} else {
|
|
206
139
|
this.stageInstance ??= null;
|
|
207
140
|
}
|
|
208
141
|
|
|
209
142
|
if ('guild_scheduled_event' in data) {
|
|
210
|
-
|
|
211
|
-
* The guild scheduled event data if there is a {@link GuildScheduledEvent} in the channel this invite is for
|
|
212
|
-
* @type {?GuildScheduledEvent}
|
|
213
|
-
*/
|
|
143
|
+
|
|
214
144
|
this.guildScheduledEvent = new GuildScheduledEvent(this.client, data.guild_scheduled_event);
|
|
215
145
|
} else {
|
|
216
146
|
this.guildScheduledEvent ??= null;
|
|
217
147
|
}
|
|
218
148
|
}
|
|
219
149
|
|
|
220
|
-
|
|
221
|
-
* The time the invite was created at
|
|
222
|
-
* @type {?Date}
|
|
223
|
-
* @readonly
|
|
224
|
-
*/
|
|
150
|
+
|
|
225
151
|
get createdAt() {
|
|
226
152
|
return this.createdTimestamp && new Date(this.createdTimestamp);
|
|
227
153
|
}
|
|
228
154
|
|
|
229
|
-
|
|
230
|
-
* Whether the invite is deletable by the client user
|
|
231
|
-
* @type {boolean}
|
|
232
|
-
* @readonly
|
|
233
|
-
*/
|
|
155
|
+
|
|
234
156
|
get deletable() {
|
|
235
157
|
const guild = this.guild;
|
|
236
158
|
if (!guild || !this.client.guilds.cache.has(guild.id)) return false;
|
|
@@ -241,11 +163,7 @@ class Invite extends Base {
|
|
|
241
163
|
);
|
|
242
164
|
}
|
|
243
165
|
|
|
244
|
-
|
|
245
|
-
* The timestamp the invite will expire at
|
|
246
|
-
* @type {?number}
|
|
247
|
-
* @readonly
|
|
248
|
-
*/
|
|
166
|
+
|
|
249
167
|
get expiresTimestamp() {
|
|
250
168
|
return (
|
|
251
169
|
this._expiresTimestamp ??
|
|
@@ -253,50 +171,28 @@ class Invite extends Base {
|
|
|
253
171
|
);
|
|
254
172
|
}
|
|
255
173
|
|
|
256
|
-
|
|
257
|
-
* The time the invite will expire at
|
|
258
|
-
* @type {?Date}
|
|
259
|
-
* @readonly
|
|
260
|
-
*/
|
|
174
|
+
|
|
261
175
|
get expiresAt() {
|
|
262
176
|
return this.expiresTimestamp && new Date(this.expiresTimestamp);
|
|
263
177
|
}
|
|
264
178
|
|
|
265
|
-
|
|
266
|
-
* The user who created this invite
|
|
267
|
-
* @type {?User}
|
|
268
|
-
* @readonly
|
|
269
|
-
*/
|
|
179
|
+
|
|
270
180
|
get inviter() {
|
|
271
181
|
return this.inviterId && this.client.users.resolve(this.inviterId);
|
|
272
182
|
}
|
|
273
183
|
|
|
274
|
-
|
|
275
|
-
* The URL to the invite
|
|
276
|
-
* @type {string}
|
|
277
|
-
* @readonly
|
|
278
|
-
*/
|
|
184
|
+
|
|
279
185
|
get url() {
|
|
280
186
|
return `${RouteBases.invite}/${this.code}`;
|
|
281
187
|
}
|
|
282
188
|
|
|
283
|
-
|
|
284
|
-
* Deletes this invite.
|
|
285
|
-
* @param {string} [reason] Reason for deleting this invite
|
|
286
|
-
* @returns {Promise<Invite>}
|
|
287
|
-
*/
|
|
189
|
+
|
|
288
190
|
async delete(reason) {
|
|
289
191
|
await this.client.rest.delete(Routes.invite(this.code), { reason });
|
|
290
192
|
return this;
|
|
291
193
|
}
|
|
292
194
|
|
|
293
|
-
|
|
294
|
-
* When concatenated with a string, this automatically concatenates the invite's URL instead of the object.
|
|
295
|
-
* @returns {string}
|
|
296
|
-
* @example
|
|
297
|
-
* // Logs: Invite: https://discord.gg/A1b2C3
|
|
298
|
-
* console.log(`Invite: ${invite}`);
|
|
299
|
-
*/
|
|
195
|
+
|
|
300
196
|
toString() {
|
|
301
197
|
return this.url;
|
|
302
198
|
}
|