@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
|
@@ -7,62 +7,19 @@ const InteractionCollector = require('../InteractionCollector');
|
|
|
7
7
|
const InteractionResponse = require('../InteractionResponse');
|
|
8
8
|
const MessagePayload = require('../MessagePayload');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* @property {string} customId The custom id of the modal
|
|
14
|
-
* @property {ActionRow[]} components The components within this modal
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Interface for classes that support shared interaction response types.
|
|
19
|
-
* @interface
|
|
20
|
-
*/
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
21
13
|
class InteractionResponses {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* @typedef {Object} InteractionDeferUpdateOptions
|
|
32
|
-
* @property {boolean} [fetchReply] Whether to fetch the reply
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Options for a reply to a {@link BaseInteraction}.
|
|
37
|
-
* @typedef {BaseMessageOptions} InteractionReplyOptions
|
|
38
|
-
* @property {boolean} [tts=false] Whether the message should be spoken aloud
|
|
39
|
-
* @property {boolean} [ephemeral] Whether the reply should be ephemeral
|
|
40
|
-
* @property {boolean} [fetchReply] Whether to fetch the reply
|
|
41
|
-
* @property {MessageFlags} [flags] Which flags to set for the message.
|
|
42
|
-
* <info>Only `MessageFlags.SuppressEmbeds` and `MessageFlags.Ephemeral` can be set.</info>
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Options for updating the message received from a {@link MessageComponentInteraction}.
|
|
47
|
-
* @typedef {MessageEditOptions} InteractionUpdateOptions
|
|
48
|
-
* @property {boolean} [fetchReply] Whether to fetch the reply
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Defers the reply to this interaction.
|
|
53
|
-
* @param {InteractionDeferReplyOptions} [options] Options for deferring the reply to this interaction
|
|
54
|
-
* @returns {Promise<Message|InteractionResponse>}
|
|
55
|
-
* @example
|
|
56
|
-
* // Defer the reply to this interaction
|
|
57
|
-
* interaction.deferReply()
|
|
58
|
-
* .then(console.log)
|
|
59
|
-
* .catch(console.error)
|
|
60
|
-
* @example
|
|
61
|
-
* // Defer to send an ephemeral reply later
|
|
62
|
-
* interaction.deferReply({ ephemeral: true })
|
|
63
|
-
* .then(console.log)
|
|
64
|
-
* .catch(console.error);
|
|
65
|
-
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
66
23
|
async deferReply(options = {}) {
|
|
67
24
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
68
25
|
this.ephemeral = options.ephemeral ?? false;
|
|
@@ -80,24 +37,7 @@ class InteractionResponses {
|
|
|
80
37
|
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
|
|
81
38
|
}
|
|
82
39
|
|
|
83
|
-
|
|
84
|
-
* Creates a reply to this interaction.
|
|
85
|
-
* <info>Use the `fetchReply` option to get the bot's reply message.</info>
|
|
86
|
-
* @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
|
|
87
|
-
* @returns {Promise<Message|InteractionResponse>}
|
|
88
|
-
* @example
|
|
89
|
-
* // Reply to the interaction and fetch the response
|
|
90
|
-
* interaction.reply({ content: 'Pong!', fetchReply: true })
|
|
91
|
-
* .then((message) => console.log(`Reply sent with content ${message.content}`))
|
|
92
|
-
* .catch(console.error);
|
|
93
|
-
* @example
|
|
94
|
-
* // Create an ephemeral reply with an embed
|
|
95
|
-
* const embed = new EmbedBuilder().setDescription('Pong!');
|
|
96
|
-
*
|
|
97
|
-
* interaction.reply({ embeds: [embed], ephemeral: true })
|
|
98
|
-
* .then(() => console.log('Reply sent.'))
|
|
99
|
-
* .catch(console.error);
|
|
100
|
-
*/
|
|
40
|
+
|
|
101
41
|
async reply(options) {
|
|
102
42
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
103
43
|
this.ephemeral = options.ephemeral ?? false;
|
|
@@ -121,38 +61,14 @@ class InteractionResponses {
|
|
|
121
61
|
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
|
|
122
62
|
}
|
|
123
63
|
|
|
124
|
-
|
|
125
|
-
* Fetches a reply to this interaction.
|
|
126
|
-
* @see Webhook#fetchMessage
|
|
127
|
-
* @param {Snowflake|'@original'} [message='@original'] The response to fetch
|
|
128
|
-
* @returns {Promise<Message>}
|
|
129
|
-
* @example
|
|
130
|
-
* // Fetch the initial reply to this interaction
|
|
131
|
-
* interaction.fetchReply()
|
|
132
|
-
* .then(reply => console.log(`Replied with ${reply.content}`))
|
|
133
|
-
* .catch(console.error);
|
|
134
|
-
*/
|
|
64
|
+
|
|
135
65
|
fetchReply(message = '@original') {
|
|
136
66
|
return this.webhook.fetchMessage(message);
|
|
137
67
|
}
|
|
138
68
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
* @property {MessageResolvable|'@original'} [message='@original'] The response to edit
|
|
143
|
-
*/
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Edits a reply to this interaction.
|
|
147
|
-
* @see Webhook#editMessage
|
|
148
|
-
* @param {string|MessagePayload|InteractionEditReplyOptions} options The new options for the message
|
|
149
|
-
* @returns {Promise<Message>}
|
|
150
|
-
* @example
|
|
151
|
-
* // Edit the initial reply to this interaction
|
|
152
|
-
* interaction.editReply('New content')
|
|
153
|
-
* .then(console.log)
|
|
154
|
-
* .catch(console.error);
|
|
155
|
-
*/
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
156
72
|
async editReply(options) {
|
|
157
73
|
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
|
|
158
74
|
const msg = await this.webhook.editMessage(options.message ?? '@original', options);
|
|
@@ -160,41 +76,18 @@ class InteractionResponses {
|
|
|
160
76
|
return msg;
|
|
161
77
|
}
|
|
162
78
|
|
|
163
|
-
|
|
164
|
-
* Deletes a reply to this interaction.
|
|
165
|
-
* @see Webhook#deleteMessage
|
|
166
|
-
* @param {MessageResolvable|'@original'} [message='@original'] The response to delete
|
|
167
|
-
* @returns {Promise<void>}
|
|
168
|
-
* @example
|
|
169
|
-
* // Delete the initial reply to this interaction
|
|
170
|
-
* interaction.deleteReply()
|
|
171
|
-
* .then(console.log)
|
|
172
|
-
* .catch(console.error);
|
|
173
|
-
*/
|
|
79
|
+
|
|
174
80
|
async deleteReply(message = '@original') {
|
|
175
81
|
await this.webhook.deleteMessage(message);
|
|
176
82
|
}
|
|
177
83
|
|
|
178
|
-
|
|
179
|
-
* Send a follow-up message to this interaction.
|
|
180
|
-
* @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
|
|
181
|
-
* @returns {Promise<Message>}
|
|
182
|
-
*/
|
|
84
|
+
|
|
183
85
|
followUp(options) {
|
|
184
86
|
if (!this.deferred && !this.replied) return Promise.reject(new DiscordjsError(ErrorCodes.InteractionNotReplied));
|
|
185
87
|
return this.webhook.send(options);
|
|
186
88
|
}
|
|
187
89
|
|
|
188
|
-
|
|
189
|
-
* Defers an update to the message to which the component was attached.
|
|
190
|
-
* @param {InteractionDeferUpdateOptions} [options] Options for deferring the update to this interaction
|
|
191
|
-
* @returns {Promise<Message|InteractionResponse>}
|
|
192
|
-
* @example
|
|
193
|
-
* // Defer updating and reset the component's loading state
|
|
194
|
-
* interaction.deferUpdate()
|
|
195
|
-
* .then(console.log)
|
|
196
|
-
* .catch(console.error);
|
|
197
|
-
*/
|
|
90
|
+
|
|
198
91
|
async deferUpdate(options = {}) {
|
|
199
92
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
200
93
|
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
@@ -208,19 +101,7 @@ class InteractionResponses {
|
|
|
208
101
|
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message?.interaction?.id);
|
|
209
102
|
}
|
|
210
103
|
|
|
211
|
-
|
|
212
|
-
* Updates the original message of the component on which the interaction was received on.
|
|
213
|
-
* @param {string|MessagePayload|InteractionUpdateOptions} options The options for the updated message
|
|
214
|
-
* @returns {Promise<Message|void>}
|
|
215
|
-
* @example
|
|
216
|
-
* // Remove the components from the message
|
|
217
|
-
* interaction.update({
|
|
218
|
-
* content: "A component interaction was received",
|
|
219
|
-
* components: []
|
|
220
|
-
* })
|
|
221
|
-
* .then(console.log)
|
|
222
|
-
* .catch(console.error);
|
|
223
|
-
*/
|
|
104
|
+
|
|
224
105
|
async update(options) {
|
|
225
106
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
226
107
|
|
|
@@ -243,11 +124,7 @@ class InteractionResponses {
|
|
|
243
124
|
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message.interaction?.id);
|
|
244
125
|
}
|
|
245
126
|
|
|
246
|
-
|
|
247
|
-
* Shows a modal component
|
|
248
|
-
* @param {ModalBuilder|ModalComponentData|APIModalInteractionResponseCallbackData} modal The modal to show
|
|
249
|
-
* @returns {Promise<void>}
|
|
250
|
-
*/
|
|
127
|
+
|
|
251
128
|
async showModal(modal) {
|
|
252
129
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
253
130
|
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
@@ -260,25 +137,9 @@ class InteractionResponses {
|
|
|
260
137
|
this.replied = true;
|
|
261
138
|
}
|
|
262
139
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
* @property {CollectorFilter} [filter] The filter applied to this collector
|
|
267
|
-
* @property {number} time Time in milliseconds to wait for an interaction before rejecting
|
|
268
|
-
*/
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Collects a single modal submit interaction that passes the filter.
|
|
272
|
-
* The Promise will reject if the time expires.
|
|
273
|
-
* @param {AwaitModalSubmitOptions} options Options to pass to the internal collector
|
|
274
|
-
* @returns {Promise<ModalSubmitInteraction>}
|
|
275
|
-
* @example
|
|
276
|
-
* // Collect a modal submit interaction
|
|
277
|
-
* const filter = (interaction) => interaction.customId === 'modal';
|
|
278
|
-
* interaction.awaitModalSubmit({ filter, time: 15_000 })
|
|
279
|
-
* .then(interaction => console.log(`${interaction.customId} was submitted!`))
|
|
280
|
-
* .catch(console.error);
|
|
281
|
-
*/
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
282
143
|
awaitModalSubmit(options) {
|
|
283
144
|
if (typeof options.time !== 'number') throw new DiscordjsError(ErrorCodes.InvalidType, 'time', 'number');
|
|
284
145
|
const _options = { ...options, max: 1, interactionType: InteractionType.ModalSubmit };
|
|
@@ -9,138 +9,44 @@ const InteractionCollector = require('../InteractionCollector');
|
|
|
9
9
|
const MessageCollector = require('../MessageCollector');
|
|
10
10
|
const MessagePayload = require('../MessagePayload');
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
* Interface for classes that have text-channel-like features.
|
|
14
|
-
* @interface
|
|
15
|
-
*/
|
|
12
|
+
|
|
16
13
|
class TextBasedChannel {
|
|
17
14
|
constructor() {
|
|
18
|
-
|
|
19
|
-
* A manager of the messages sent to this channel
|
|
20
|
-
* @type {MessageManager}
|
|
21
|
-
*/
|
|
15
|
+
|
|
22
16
|
this.messages = new MessageManager(this);
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
* The channel's last message id, if one was sent
|
|
26
|
-
* @type {?Snowflake}
|
|
27
|
-
*/
|
|
18
|
+
|
|
28
19
|
this.lastMessageId = null;
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
* The timestamp when the last pinned message was pinned, if there was one
|
|
32
|
-
* @type {?number}
|
|
33
|
-
*/
|
|
21
|
+
|
|
34
22
|
this.lastPinTimestamp = null;
|
|
35
23
|
}
|
|
36
24
|
|
|
37
|
-
|
|
38
|
-
* The Message object of the last message in the channel, if one was sent
|
|
39
|
-
* @type {?Message}
|
|
40
|
-
* @readonly
|
|
41
|
-
*/
|
|
25
|
+
|
|
42
26
|
get lastMessage() {
|
|
43
27
|
return this.messages.resolve(this.lastMessageId);
|
|
44
28
|
}
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
* The date when the last pinned message was pinned, if there was one
|
|
48
|
-
* @type {?Date}
|
|
49
|
-
* @readonly
|
|
50
|
-
*/
|
|
30
|
+
|
|
51
31
|
get lastPinAt() {
|
|
52
32
|
return this.lastPinTimestamp && new Date(this.lastPinTimestamp);
|
|
53
33
|
}
|
|
54
34
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @typedef {Object} ReplyOptions
|
|
71
|
-
* @property {MessageResolvable} messageReference The message to reply to (must be in the same channel and not system)
|
|
72
|
-
* @property {boolean} [failIfNotExists=this.client.options.failIfNotExists] Whether to error if the referenced
|
|
73
|
-
* message does not exist (creates a standard message in this case when false)
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The options for sending a message.
|
|
78
|
-
* @typedef {BaseMessageOptions} BaseMessageCreateOptions
|
|
79
|
-
* @property {boolean} [tts=false] Whether the message should be spoken aloud
|
|
80
|
-
* @property {string} [nonce=''] The nonce for the message
|
|
81
|
-
* @property {StickerResolvable[]} [stickers=[]] The stickers to send in the message
|
|
82
|
-
* @property {MessageFlags} [flags] Which flags to set for the message.
|
|
83
|
-
* <info>Only `MessageFlags.SuppressEmbeds` and `MessageFlags.SuppressNotifications` can be set.</info>
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The options for sending a message.
|
|
88
|
-
* @typedef {BaseMessageCreateOptions} MessageCreateOptions
|
|
89
|
-
* @property {ReplyOptions} [reply] The options for replying to a message
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Options provided to control parsing of mentions by Discord
|
|
94
|
-
* @typedef {Object} MessageMentionOptions
|
|
95
|
-
* @property {MessageMentionTypes[]} [parse] Types of mentions to be parsed
|
|
96
|
-
* @property {Snowflake[]} [users] Snowflakes of Users to be parsed as mentions
|
|
97
|
-
* @property {Snowflake[]} [roles] Snowflakes of Roles to be parsed as mentions
|
|
98
|
-
* @property {boolean} [repliedUser=true] Whether the author of the Message being replied to should be pinged
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Types of mentions to enable in MessageMentionOptions.
|
|
103
|
-
* - `roles`
|
|
104
|
-
* - `users`
|
|
105
|
-
* - `everyone`
|
|
106
|
-
* @typedef {string} MessageMentionTypes
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @typedef {Object} FileOptions
|
|
111
|
-
* @property {BufferResolvable} attachment File to attach
|
|
112
|
-
* @property {string} [name='file.jpg'] Filename of the attachment
|
|
113
|
-
* @property {string} description The description of the file
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Sends a message to this channel.
|
|
118
|
-
* @param {string|MessagePayload|MessageCreateOptions} options The options to provide
|
|
119
|
-
* @returns {Promise<Message>}
|
|
120
|
-
* @example
|
|
121
|
-
* // Send a basic message
|
|
122
|
-
* channel.send('hello!')
|
|
123
|
-
* .then(message => console.log(`Sent message: ${message.content}`))
|
|
124
|
-
* .catch(console.error);
|
|
125
|
-
* @example
|
|
126
|
-
* // Send a remote file
|
|
127
|
-
* channel.send({
|
|
128
|
-
* files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
|
|
129
|
-
* })
|
|
130
|
-
* .then(console.log)
|
|
131
|
-
* .catch(console.error);
|
|
132
|
-
* @example
|
|
133
|
-
* // Send a local file
|
|
134
|
-
* channel.send({
|
|
135
|
-
* files: [{
|
|
136
|
-
* attachment: 'entire/path/to/file.jpg',
|
|
137
|
-
* name: 'file.jpg',
|
|
138
|
-
* description: 'A description of the file'
|
|
139
|
-
* }]
|
|
140
|
-
* })
|
|
141
|
-
* .then(console.log)
|
|
142
|
-
* .catch(console.error);
|
|
143
|
-
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
144
50
|
async send(options) {
|
|
145
51
|
const User = require('../User');
|
|
146
52
|
const { GuildMember } = require('../GuildMember');
|
|
@@ -164,51 +70,19 @@ class TextBasedChannel {
|
|
|
164
70
|
return this.messages.cache.get(d.id) ?? this.messages._add(d);
|
|
165
71
|
}
|
|
166
72
|
|
|
167
|
-
|
|
168
|
-
* Sends a typing indicator in the channel.
|
|
169
|
-
* @returns {Promise<void>} Resolves upon the typing status being sent
|
|
170
|
-
* @example
|
|
171
|
-
* // Start typing in a channel
|
|
172
|
-
* channel.sendTyping();
|
|
173
|
-
*/
|
|
73
|
+
|
|
174
74
|
async sendTyping() {
|
|
175
75
|
await this.client.rest.post(Routes.channelTyping(this.id));
|
|
176
76
|
}
|
|
177
77
|
|
|
178
|
-
|
|
179
|
-
* Creates a Message Collector.
|
|
180
|
-
* @param {MessageCollectorOptions} [options={}] The options to pass to the collector
|
|
181
|
-
* @returns {MessageCollector}
|
|
182
|
-
* @example
|
|
183
|
-
* // Create a message collector
|
|
184
|
-
* const filter = m => m.content.includes('discord');
|
|
185
|
-
* const collector = channel.createMessageCollector({ filter, time: 15_000 });
|
|
186
|
-
* collector.on('collect', m => console.log(`Collected ${m.content}`));
|
|
187
|
-
* collector.on('end', collected => console.log(`Collected ${collected.size} items`));
|
|
188
|
-
*/
|
|
78
|
+
|
|
189
79
|
createMessageCollector(options = {}) {
|
|
190
80
|
return new MessageCollector(this, options);
|
|
191
81
|
}
|
|
192
82
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
* @property {string[]} [errors] Stop/end reasons that cause the promise to reject
|
|
197
|
-
*/
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Similar to createMessageCollector but in promise form.
|
|
201
|
-
* Resolves with a collection of messages that pass the specified filter.
|
|
202
|
-
* @param {AwaitMessagesOptions} [options={}] Optional options to pass to the internal collector
|
|
203
|
-
* @returns {Promise<Collection<Snowflake, Message>>}
|
|
204
|
-
* @example
|
|
205
|
-
* // Await !vote messages
|
|
206
|
-
* const filter = m => m.content.startsWith('!vote');
|
|
207
|
-
* // Errors: ['time'] treats ending because of the time limit as an error
|
|
208
|
-
* channel.awaitMessages({ filter, max: 4, time: 60_000, errors: ['time'] })
|
|
209
|
-
* .then(collected => console.log(collected.size))
|
|
210
|
-
* .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
|
|
211
|
-
*/
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
212
86
|
awaitMessages(options = {}) {
|
|
213
87
|
return new Promise((resolve, reject) => {
|
|
214
88
|
const collector = this.createMessageCollector(options);
|
|
@@ -222,17 +96,7 @@ class TextBasedChannel {
|
|
|
222
96
|
});
|
|
223
97
|
}
|
|
224
98
|
|
|
225
|
-
|
|
226
|
-
* Creates a component interaction collector.
|
|
227
|
-
* @param {MessageComponentCollectorOptions} [options={}] Options to send to the collector
|
|
228
|
-
* @returns {InteractionCollector}
|
|
229
|
-
* @example
|
|
230
|
-
* // Create a button interaction collector
|
|
231
|
-
* const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
|
|
232
|
-
* const collector = channel.createMessageComponentCollector({ filter, time: 15_000 });
|
|
233
|
-
* collector.on('collect', i => console.log(`Collected ${i.customId}`));
|
|
234
|
-
* collector.on('end', collected => console.log(`Collected ${collected.size} items`));
|
|
235
|
-
*/
|
|
99
|
+
|
|
236
100
|
createMessageComponentCollector(options = {}) {
|
|
237
101
|
return new InteractionCollector(this.client, {
|
|
238
102
|
...options,
|
|
@@ -241,18 +105,7 @@ class TextBasedChannel {
|
|
|
241
105
|
});
|
|
242
106
|
}
|
|
243
107
|
|
|
244
|
-
|
|
245
|
-
* Collects a single component interaction that passes the filter.
|
|
246
|
-
* The Promise will reject if the time expires.
|
|
247
|
-
* @param {AwaitMessageComponentOptions} [options={}] Options to pass to the internal collector
|
|
248
|
-
* @returns {Promise<MessageComponentInteraction>}
|
|
249
|
-
* @example
|
|
250
|
-
* // Collect a message component interaction
|
|
251
|
-
* const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
|
|
252
|
-
* channel.awaitMessageComponent({ filter, time: 15_000 })
|
|
253
|
-
* .then(interaction => console.log(`${interaction.customId} was clicked!`))
|
|
254
|
-
* .catch(console.error);
|
|
255
|
-
*/
|
|
108
|
+
|
|
256
109
|
awaitMessageComponent(options = {}) {
|
|
257
110
|
const _options = { ...options, max: 1 };
|
|
258
111
|
return new Promise((resolve, reject) => {
|
|
@@ -265,18 +118,7 @@ class TextBasedChannel {
|
|
|
265
118
|
});
|
|
266
119
|
}
|
|
267
120
|
|
|
268
|
-
|
|
269
|
-
* Bulk deletes given messages that are newer than two weeks.
|
|
270
|
-
* @param {Collection<Snowflake, Message>|MessageResolvable[]|number} messages
|
|
271
|
-
* Messages or number of messages to delete
|
|
272
|
-
* @param {boolean} [filterOld=false] Filter messages to remove those which are older than two weeks automatically
|
|
273
|
-
* @returns {Promise<Collection<Snowflake, Message|undefined>>} Returns the deleted messages
|
|
274
|
-
* @example
|
|
275
|
-
* // Bulk delete messages
|
|
276
|
-
* channel.bulkDelete(5)
|
|
277
|
-
* .then(messages => console.log(`Bulk deleted ${messages.size} messages`))
|
|
278
|
-
* .catch(console.error);
|
|
279
|
-
*/
|
|
121
|
+
|
|
280
122
|
async bulkDelete(messages, filterOld = false) {
|
|
281
123
|
if (Array.isArray(messages) || messages instanceof Collection) {
|
|
282
124
|
let messageIds = messages instanceof Collection ? [...messages.keys()] : messages.map(m => m.id ?? m);
|
|
@@ -318,61 +160,24 @@ class TextBasedChannel {
|
|
|
318
160
|
throw new DiscordjsTypeError(ErrorCodes.MessageBulkDeleteType);
|
|
319
161
|
}
|
|
320
162
|
|
|
321
|
-
|
|
322
|
-
* Fetches all webhooks for the channel.
|
|
323
|
-
* @returns {Promise<Collection<Snowflake, Webhook>>}
|
|
324
|
-
* @example
|
|
325
|
-
* // Fetch webhooks
|
|
326
|
-
* channel.fetchWebhooks()
|
|
327
|
-
* .then(hooks => console.log(`This channel has ${hooks.size} hooks`))
|
|
328
|
-
* .catch(console.error);
|
|
329
|
-
*/
|
|
163
|
+
|
|
330
164
|
fetchWebhooks() {
|
|
331
165
|
return this.guild.channels.fetchWebhooks(this.id);
|
|
332
166
|
}
|
|
333
167
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
* @property {string} name The name of the webhook
|
|
338
|
-
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] Avatar for the webhook
|
|
339
|
-
* @property {string} [reason] Reason for creating the webhook
|
|
340
|
-
*/
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Creates a webhook for the channel.
|
|
344
|
-
* @param {ChannelWebhookCreateOptions} [options] Options for creating the webhook
|
|
345
|
-
* @returns {Promise<Webhook>} Returns the created Webhook
|
|
346
|
-
* @example
|
|
347
|
-
* // Create a webhook for the current channel
|
|
348
|
-
* channel.createWebhook({
|
|
349
|
-
* name: 'Snek',
|
|
350
|
-
* avatar: 'https://i.imgur.com/mI8XcpG.jpg',
|
|
351
|
-
* reason: 'Needed a cool new Webhook'
|
|
352
|
-
* })
|
|
353
|
-
* .then(console.log)
|
|
354
|
-
* .catch(console.error)
|
|
355
|
-
*/
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
356
171
|
createWebhook(options) {
|
|
357
172
|
return this.guild.channels.createWebhook({ channel: this.id, ...options });
|
|
358
173
|
}
|
|
359
174
|
|
|
360
|
-
|
|
361
|
-
* Sets the rate limit per user (slowmode) for this channel.
|
|
362
|
-
* @param {number} rateLimitPerUser The new rate limit in seconds
|
|
363
|
-
* @param {string} [reason] Reason for changing the channel's rate limit
|
|
364
|
-
* @returns {Promise<this>}
|
|
365
|
-
*/
|
|
175
|
+
|
|
366
176
|
setRateLimitPerUser(rateLimitPerUser, reason) {
|
|
367
177
|
return this.edit({ rateLimitPerUser, reason });
|
|
368
178
|
}
|
|
369
179
|
|
|
370
|
-
|
|
371
|
-
* Sets whether this channel is flagged as NSFW.
|
|
372
|
-
* @param {boolean} [nsfw=true] Whether the channel should be considered NSFW
|
|
373
|
-
* @param {string} [reason] Reason for changing the channel's NSFW flag
|
|
374
|
-
* @returns {Promise<this>}
|
|
375
|
-
*/
|
|
180
|
+
|
|
376
181
|
setNSFW(nsfw = true, reason) {
|
|
377
182
|
return this.edit({ nsfw, reason });
|
|
378
183
|
}
|
|
@@ -408,6 +213,6 @@ class TextBasedChannel {
|
|
|
408
213
|
|
|
409
214
|
module.exports = TextBasedChannel;
|
|
410
215
|
|
|
411
|
-
|
|
412
|
-
|
|
216
|
+
|
|
217
|
+
|
|
413
218
|
const MessageManager = require('../../managers/MessageManager');
|