@velliajs/discord 1.0.2 → 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/README.md +4 -11
- package/package.json +3 -3
- 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
|
@@ -6,35 +6,19 @@ const ReactionEmoji = require('./ReactionEmoji');
|
|
|
6
6
|
const ReactionUserManager = require('../managers/ReactionUserManager');
|
|
7
7
|
const { flatten } = require('../util/Util');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* Represents a reaction to a message.
|
|
11
|
-
*/
|
|
9
|
+
|
|
12
10
|
class MessageReaction {
|
|
13
11
|
constructor(client, data, message) {
|
|
14
|
-
|
|
15
|
-
* The client that instantiated this message reaction
|
|
16
|
-
* @name MessageReaction#client
|
|
17
|
-
* @type {Client}
|
|
18
|
-
* @readonly
|
|
19
|
-
*/
|
|
12
|
+
|
|
20
13
|
Object.defineProperty(this, 'client', { value: client });
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
* The message that this reaction refers to
|
|
24
|
-
* @type {Message}
|
|
25
|
-
*/
|
|
15
|
+
|
|
26
16
|
this.message = message;
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
* Whether the client has given this reaction
|
|
30
|
-
* @type {boolean}
|
|
31
|
-
*/
|
|
18
|
+
|
|
32
19
|
this.me = data.me;
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
* A manager of the users that have given this reaction
|
|
36
|
-
* @type {ReactionUserManager}
|
|
37
|
-
*/
|
|
21
|
+
|
|
38
22
|
this.users = new ReactionUserManager(this, this.me ? [client.user] : []);
|
|
39
23
|
|
|
40
24
|
this._emoji = new ReactionEmoji(this, data.emoji);
|
|
@@ -44,26 +28,17 @@ class MessageReaction {
|
|
|
44
28
|
|
|
45
29
|
_patch(data) {
|
|
46
30
|
if ('count' in data) {
|
|
47
|
-
|
|
48
|
-
* The number of people that have given the same reaction
|
|
49
|
-
* @type {?number}
|
|
50
|
-
*/
|
|
31
|
+
|
|
51
32
|
this.count ??= data.count;
|
|
52
33
|
}
|
|
53
34
|
}
|
|
54
35
|
|
|
55
|
-
|
|
56
|
-
* Makes the client user react with this reaction
|
|
57
|
-
* @returns {Promise<MessageReaction>}
|
|
58
|
-
*/
|
|
36
|
+
|
|
59
37
|
react() {
|
|
60
38
|
return this.message.react(this.emoji);
|
|
61
39
|
}
|
|
62
40
|
|
|
63
|
-
|
|
64
|
-
* Removes all users from this reaction.
|
|
65
|
-
* @returns {Promise<MessageReaction>}
|
|
66
|
-
*/
|
|
41
|
+
|
|
67
42
|
async remove() {
|
|
68
43
|
await this.client.rest.delete(
|
|
69
44
|
Routes.channelMessageReaction(this.message.channelId, this.message.id, this._emoji.identifier),
|
|
@@ -71,16 +46,10 @@ class MessageReaction {
|
|
|
71
46
|
return this;
|
|
72
47
|
}
|
|
73
48
|
|
|
74
|
-
|
|
75
|
-
* The emoji of this reaction. Either a {@link GuildEmoji} object for known custom emojis, or a {@link ReactionEmoji}
|
|
76
|
-
* object which has fewer properties. Whatever the prototype of the emoji, it will still have
|
|
77
|
-
* `name`, `id`, `identifier` and `toString()`
|
|
78
|
-
* @type {GuildEmoji|ReactionEmoji}
|
|
79
|
-
* @readonly
|
|
80
|
-
*/
|
|
49
|
+
|
|
81
50
|
get emoji() {
|
|
82
51
|
if (this._emoji instanceof GuildEmoji) return this._emoji;
|
|
83
|
-
|
|
52
|
+
|
|
84
53
|
if (this._emoji.id) {
|
|
85
54
|
const emojis = this.message.client.emojis.cache;
|
|
86
55
|
if (emojis.has(this._emoji.id)) {
|
|
@@ -92,23 +61,16 @@ class MessageReaction {
|
|
|
92
61
|
return this._emoji;
|
|
93
62
|
}
|
|
94
63
|
|
|
95
|
-
|
|
96
|
-
* Whether or not this reaction is a partial
|
|
97
|
-
* @type {boolean}
|
|
98
|
-
* @readonly
|
|
99
|
-
*/
|
|
64
|
+
|
|
100
65
|
get partial() {
|
|
101
66
|
return this.count === null;
|
|
102
67
|
}
|
|
103
68
|
|
|
104
|
-
|
|
105
|
-
* Fetch this reaction.
|
|
106
|
-
* @returns {Promise<MessageReaction>}
|
|
107
|
-
*/
|
|
69
|
+
|
|
108
70
|
async fetch() {
|
|
109
71
|
const message = await this.message.fetch();
|
|
110
72
|
const existing = message.reactions.cache.get(this.emoji.id ?? this.emoji.name);
|
|
111
|
-
|
|
73
|
+
|
|
112
74
|
this._patch(existing ?? { count: 0 });
|
|
113
75
|
return this;
|
|
114
76
|
}
|
|
@@ -4,10 +4,7 @@ const { ModalBuilder: BuildersModal, ComponentBuilder } = require('@discordjs/bu
|
|
|
4
4
|
const { isJSONEncodable } = require('@discordjs/util');
|
|
5
5
|
const { toSnakeCase } = require('../util/Transformers');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Represents a modal builder.
|
|
9
|
-
* @extends {BuildersModal}
|
|
10
|
-
*/
|
|
7
|
+
|
|
11
8
|
class ModalBuilder extends BuildersModal {
|
|
12
9
|
constructor({ components, ...data } = {}) {
|
|
13
10
|
super({
|
|
@@ -16,11 +13,7 @@ class ModalBuilder extends BuildersModal {
|
|
|
16
13
|
});
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
* Creates a new modal builder from JSON data
|
|
21
|
-
* @param {ModalBuilder|APIModalComponent} other The other data
|
|
22
|
-
* @returns {ModalBuilder}
|
|
23
|
-
*/
|
|
16
|
+
|
|
24
17
|
static from(other) {
|
|
25
18
|
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
|
26
19
|
}
|
|
@@ -28,7 +21,4 @@ class ModalBuilder extends BuildersModal {
|
|
|
28
21
|
|
|
29
22
|
module.exports = ModalBuilder;
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
* @external BuildersModal
|
|
33
|
-
* @see {@link https://discord.js.org/docs/packages/builders/stable/ModalBuilder:Class}
|
|
34
|
-
*/
|
|
24
|
+
|
|
@@ -4,33 +4,20 @@ const { Collection } = require('@discordjs/collection');
|
|
|
4
4
|
const { ComponentType } = require('discord-api-types/v10');
|
|
5
5
|
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Represents the serialized fields from a modal submit interaction
|
|
9
|
-
*/
|
|
7
|
+
|
|
10
8
|
class ModalSubmitFields {
|
|
11
9
|
constructor(components) {
|
|
12
|
-
|
|
13
|
-
* The components within the modal
|
|
14
|
-
* @type {ActionRowModalData[]}
|
|
15
|
-
*/
|
|
10
|
+
|
|
16
11
|
this.components = components;
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
* The extracted fields from the modal
|
|
20
|
-
* @type {Collection<string, ModalData>}
|
|
21
|
-
*/
|
|
13
|
+
|
|
22
14
|
this.fields = components.reduce((accumulator, next) => {
|
|
23
15
|
next.components.forEach(c => accumulator.set(c.customId, c));
|
|
24
16
|
return accumulator;
|
|
25
17
|
}, new Collection());
|
|
26
18
|
}
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
* Gets a field given a custom id from a component
|
|
30
|
-
* @param {string} customId The custom id of the component
|
|
31
|
-
* @param {ComponentType} [type] The type of the component
|
|
32
|
-
* @returns {ModalData}
|
|
33
|
-
*/
|
|
20
|
+
|
|
34
21
|
getField(customId, type) {
|
|
35
22
|
const field = this.fields.get(customId);
|
|
36
23
|
if (!field) throw new DiscordjsTypeError(ErrorCodes.ModalSubmitInteractionFieldNotFound, customId);
|
|
@@ -42,11 +29,7 @@ class ModalSubmitFields {
|
|
|
42
29
|
return field;
|
|
43
30
|
}
|
|
44
31
|
|
|
45
|
-
|
|
46
|
-
* Gets the value of a text input component given a custom id
|
|
47
|
-
* @param {string} customId The custom id of the text input component
|
|
48
|
-
* @returns {string}
|
|
49
|
-
*/
|
|
32
|
+
|
|
50
33
|
getTextInputValue(customId) {
|
|
51
34
|
return this.getField(customId, ComponentType.TextInput).value;
|
|
52
35
|
}
|
|
@@ -8,85 +8,44 @@ const InteractionResponses = require('./interfaces/InteractionResponses');
|
|
|
8
8
|
|
|
9
9
|
const getMessage = lazy(() => require('./Message').Message);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Object} ActionRowModalData
|
|
20
|
-
* @property {ModalData[]} components The components of this action row
|
|
21
|
-
* @property {ComponentType} type The component type of the action row
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Represents a modal interaction
|
|
26
|
-
* @extends {BaseInteraction}
|
|
27
|
-
* @implements {InteractionResponses}
|
|
28
|
-
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
29
16
|
class ModalSubmitInteraction extends BaseInteraction {
|
|
30
17
|
constructor(client, data) {
|
|
31
18
|
super(client, data);
|
|
32
|
-
|
|
33
|
-
* The custom id of the modal.
|
|
34
|
-
* @type {string}
|
|
35
|
-
*/
|
|
19
|
+
|
|
36
20
|
this.customId = data.data.custom_id;
|
|
37
21
|
|
|
38
22
|
if ('message' in data) {
|
|
39
|
-
|
|
40
|
-
* The message associated with this interaction
|
|
41
|
-
* @type {?Message}
|
|
42
|
-
*/
|
|
23
|
+
|
|
43
24
|
this.message = this.channel?.messages._add(data.message) ?? new (getMessage())(this.client, data.message);
|
|
44
25
|
} else {
|
|
45
26
|
this.message = null;
|
|
46
27
|
}
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
* The components within the modal
|
|
50
|
-
* @type {ActionRowModalData[]}
|
|
51
|
-
*/
|
|
29
|
+
|
|
52
30
|
this.components = data.data.components?.map(c => ModalSubmitInteraction.transformComponent(c));
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
* The fields within the modal
|
|
56
|
-
* @type {ModalSubmitFields}
|
|
57
|
-
*/
|
|
32
|
+
|
|
58
33
|
this.fields = new ModalSubmitFields(this.components);
|
|
59
34
|
|
|
60
|
-
|
|
61
|
-
* Whether the reply to this interaction has been deferred
|
|
62
|
-
* @type {boolean}
|
|
63
|
-
*/
|
|
35
|
+
|
|
64
36
|
this.deferred = false;
|
|
65
37
|
|
|
66
|
-
|
|
67
|
-
* Whether this interaction has already been replied to
|
|
68
|
-
* @type {boolean}
|
|
69
|
-
*/
|
|
38
|
+
|
|
70
39
|
this.replied = false;
|
|
71
40
|
|
|
72
|
-
|
|
73
|
-
* Whether the reply to this interaction is ephemeral
|
|
74
|
-
* @type {?boolean}
|
|
75
|
-
*/
|
|
41
|
+
|
|
76
42
|
this.ephemeral = null;
|
|
77
43
|
|
|
78
|
-
|
|
79
|
-
* An associated interaction webhook, can be used to further interact with this interaction
|
|
80
|
-
* @type {InteractionWebhook}
|
|
81
|
-
*/
|
|
44
|
+
|
|
82
45
|
this.webhook = new InteractionWebhook(this.client, this.applicationId, this.token);
|
|
83
46
|
}
|
|
84
47
|
|
|
85
|
-
|
|
86
|
-
* Transforms component data to discord.js-compatible data
|
|
87
|
-
* @param {*} rawComponent The data to transform
|
|
88
|
-
* @returns {ModalData[]}
|
|
89
|
-
*/
|
|
48
|
+
|
|
90
49
|
static transformComponent(rawComponent) {
|
|
91
50
|
return {
|
|
92
51
|
value: rawComponent.value,
|
|
@@ -96,16 +55,13 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
96
55
|
};
|
|
97
56
|
}
|
|
98
57
|
|
|
99
|
-
|
|
100
|
-
* Whether this is from a {@link MessageComponentInteraction}.
|
|
101
|
-
* @returns {boolean}
|
|
102
|
-
*/
|
|
58
|
+
|
|
103
59
|
isFromMessage() {
|
|
104
60
|
return Boolean(this.message);
|
|
105
61
|
}
|
|
106
62
|
|
|
107
|
-
|
|
108
|
-
|
|
63
|
+
|
|
64
|
+
|
|
109
65
|
deferReply() {}
|
|
110
66
|
reply() {}
|
|
111
67
|
fetchReply() {}
|
|
@@ -4,23 +4,9 @@ const { Routes } = require('discord-api-types/v10');
|
|
|
4
4
|
const BaseGuildTextChannel = require('./BaseGuildTextChannel');
|
|
5
5
|
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Represents a guild news channel on Discord.
|
|
9
|
-
* @extends {BaseGuildTextChannel}
|
|
10
|
-
*/
|
|
7
|
+
|
|
11
8
|
class NewsChannel extends BaseGuildTextChannel {
|
|
12
|
-
|
|
13
|
-
* Adds the target to this channel's followers.
|
|
14
|
-
* @param {TextChannelResolvable} channel The channel where the webhook should be created
|
|
15
|
-
* @param {string} [reason] Reason for creating the webhook
|
|
16
|
-
* @returns {Promise<NewsChannel>}
|
|
17
|
-
* @example
|
|
18
|
-
* if (channel.type === ChannelType.GuildAnnouncement) {
|
|
19
|
-
* channel.addFollower('222197033908436994', 'Important announcements')
|
|
20
|
-
* .then(() => console.log('Added follower'))
|
|
21
|
-
* .catch(console.error);
|
|
22
|
-
* }
|
|
23
|
-
*/
|
|
9
|
+
|
|
24
10
|
async addFollower(channel, reason) {
|
|
25
11
|
const channelId = this.guild.channels.resolveId(channel);
|
|
26
12
|
if (!channelId) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
|
|
@@ -3,24 +3,15 @@
|
|
|
3
3
|
const BaseGuild = require('./BaseGuild');
|
|
4
4
|
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* A partial guild received when using {@link GuildManager#fetch} to fetch multiple guilds.
|
|
8
|
-
* @extends {BaseGuild}
|
|
9
|
-
*/
|
|
6
|
+
|
|
10
7
|
class OAuth2Guild extends BaseGuild {
|
|
11
8
|
constructor(client, data) {
|
|
12
9
|
super(client, data);
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
* Whether the client user is the owner of the guild
|
|
16
|
-
* @type {boolean}
|
|
17
|
-
*/
|
|
11
|
+
|
|
18
12
|
this.owner = data.owner;
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
* The permissions that the client user has in this guild
|
|
22
|
-
* @type {Readonly<PermissionsBitField>}
|
|
23
|
-
*/
|
|
14
|
+
|
|
24
15
|
this.permissions = new PermissionsBitField(BigInt(data.permissions)).freeze();
|
|
25
16
|
}
|
|
26
17
|
}
|
|
@@ -3,47 +3,27 @@
|
|
|
3
3
|
const { BaseChannel } = require('./BaseChannel');
|
|
4
4
|
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* Represents a Partial Group DM Channel on Discord.
|
|
8
|
-
* @extends {BaseChannel}
|
|
9
|
-
*/
|
|
6
|
+
|
|
10
7
|
class PartialGroupDMChannel extends BaseChannel {
|
|
11
8
|
constructor(client, data) {
|
|
12
9
|
super(client, data);
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
|
|
15
12
|
this.flags = null;
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
* The name of this Group DM Channel
|
|
19
|
-
* @type {?string}
|
|
20
|
-
*/
|
|
14
|
+
|
|
21
15
|
this.name = data.name;
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
* The hash of the channel icon
|
|
25
|
-
* @type {?string}
|
|
26
|
-
*/
|
|
17
|
+
|
|
27
18
|
this.icon = data.icon;
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
* Recipient data received in a {@link PartialGroupDMChannel}.
|
|
31
|
-
* @typedef {Object} PartialRecipient
|
|
32
|
-
* @property {string} username The username of the recipient
|
|
33
|
-
*/
|
|
20
|
+
|
|
34
21
|
|
|
35
|
-
|
|
36
|
-
* The recipients of this Group DM Channel.
|
|
37
|
-
* @type {PartialRecipient[]}
|
|
38
|
-
*/
|
|
22
|
+
|
|
39
23
|
this.recipients = data.recipients;
|
|
40
24
|
}
|
|
41
25
|
|
|
42
|
-
|
|
43
|
-
* The URL to this channel's icon.
|
|
44
|
-
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
45
|
-
* @returns {?string}
|
|
46
|
-
*/
|
|
26
|
+
|
|
47
27
|
iconURL(options = {}) {
|
|
48
28
|
return this.icon && this.client.rest.cdn.channelIcon(this.id, this.icon, options);
|
|
49
29
|
}
|
|
@@ -6,80 +6,44 @@ const { Role } = require('./Role');
|
|
|
6
6
|
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
|
7
7
|
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* Represents a permission overwrite for a role or member in a guild channel.
|
|
11
|
-
* @extends {Base}
|
|
12
|
-
*/
|
|
9
|
+
|
|
13
10
|
class PermissionOverwrites extends Base {
|
|
14
11
|
constructor(client, data, channel) {
|
|
15
12
|
super(client);
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
* The GuildChannel this overwrite is for
|
|
19
|
-
* @name PermissionOverwrites#channel
|
|
20
|
-
* @type {GuildChannel}
|
|
21
|
-
* @readonly
|
|
22
|
-
*/
|
|
14
|
+
|
|
23
15
|
Object.defineProperty(this, 'channel', { value: channel });
|
|
24
16
|
|
|
25
17
|
if (data) this._patch(data);
|
|
26
18
|
}
|
|
27
19
|
|
|
28
20
|
_patch(data) {
|
|
29
|
-
|
|
30
|
-
* The overwrite's id, either a {@link User} or a {@link Role} id
|
|
31
|
-
* @type {Snowflake}
|
|
32
|
-
*/
|
|
21
|
+
|
|
33
22
|
this.id = data.id;
|
|
34
23
|
|
|
35
24
|
if ('type' in data) {
|
|
36
|
-
|
|
37
|
-
* The type of this overwrite
|
|
38
|
-
* @type {OverwriteType}
|
|
39
|
-
*/
|
|
25
|
+
|
|
40
26
|
this.type = data.type;
|
|
41
27
|
}
|
|
42
28
|
|
|
43
29
|
if ('deny' in data) {
|
|
44
|
-
|
|
45
|
-
* The permissions that are denied for the user or role.
|
|
46
|
-
* @type {Readonly<PermissionsBitField>}
|
|
47
|
-
*/
|
|
30
|
+
|
|
48
31
|
this.deny = new PermissionsBitField(BigInt(data.deny)).freeze();
|
|
49
32
|
}
|
|
50
33
|
|
|
51
34
|
if ('allow' in data) {
|
|
52
|
-
|
|
53
|
-
* The permissions that are allowed for the user or role.
|
|
54
|
-
* @type {Readonly<PermissionsBitField>}
|
|
55
|
-
*/
|
|
35
|
+
|
|
56
36
|
this.allow = new PermissionsBitField(BigInt(data.allow)).freeze();
|
|
57
37
|
}
|
|
58
38
|
}
|
|
59
39
|
|
|
60
|
-
|
|
61
|
-
* Edits this Permission Overwrite.
|
|
62
|
-
* @param {PermissionOverwriteOptions} options The options for the update
|
|
63
|
-
* @param {string} [reason] Reason for creating/editing this overwrite
|
|
64
|
-
* @returns {Promise<PermissionOverwrites>}
|
|
65
|
-
* @example
|
|
66
|
-
* // Update permission overwrites
|
|
67
|
-
* permissionOverwrites.edit({
|
|
68
|
-
* SendMessages: false
|
|
69
|
-
* })
|
|
70
|
-
* .then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
|
|
71
|
-
* .catch(console.error);
|
|
72
|
-
*/
|
|
40
|
+
|
|
73
41
|
async edit(options, reason) {
|
|
74
42
|
await this.channel.permissionOverwrites.upsert(this.id, options, { type: this.type, reason }, this);
|
|
75
43
|
return this;
|
|
76
44
|
}
|
|
77
45
|
|
|
78
|
-
|
|
79
|
-
* Deletes this Permission Overwrite.
|
|
80
|
-
* @param {string} [reason] Reason for deleting this overwrite
|
|
81
|
-
* @returns {Promise<PermissionOverwrites>}
|
|
82
|
-
*/
|
|
46
|
+
|
|
83
47
|
async delete(reason) {
|
|
84
48
|
await this.channel.permissionOverwrites.delete(this.id, reason);
|
|
85
49
|
return this;
|
|
@@ -94,30 +58,11 @@ class PermissionOverwrites extends Base {
|
|
|
94
58
|
};
|
|
95
59
|
}
|
|
96
60
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
* 'EmbedLinks': null,
|
|
103
|
-
* 'AttachFiles': false,
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
106
|
-
* @typedef {Object} PermissionOverwriteOptions
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @typedef {Object} ResolvedOverwriteOptions
|
|
111
|
-
* @property {PermissionsBitField} allow The allowed permissions
|
|
112
|
-
* @property {PermissionsBitField} deny The denied permissions
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Resolves bitfield permissions overwrites from an object.
|
|
117
|
-
* @param {PermissionOverwriteOptions} options The options for the update
|
|
118
|
-
* @param {ResolvedOverwriteOptions} initialPermissions The initial permissions
|
|
119
|
-
* @returns {ResolvedOverwriteOptions}
|
|
120
|
-
*/
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
121
66
|
static resolveOverwriteOptions(options, { allow, deny } = {}) {
|
|
122
67
|
allow = new PermissionsBitField(allow);
|
|
123
68
|
deny = new PermissionsBitField(deny);
|
|
@@ -138,37 +83,13 @@ class PermissionOverwrites extends Base {
|
|
|
138
83
|
return { allow, deny };
|
|
139
84
|
}
|
|
140
85
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Data that can be resolved into {@link RawOverwriteData}. This can be:
|
|
152
|
-
* * PermissionOverwrites
|
|
153
|
-
* * OverwriteData
|
|
154
|
-
* @typedef {PermissionOverwrites|OverwriteData} OverwriteResolvable
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Data that can be used for a permission overwrite
|
|
159
|
-
* @typedef {Object} OverwriteData
|
|
160
|
-
* @property {GuildMemberResolvable|RoleResolvable} id Member or role this overwrite is for
|
|
161
|
-
* @property {PermissionResolvable} [allow] The permissions to allow
|
|
162
|
-
* @property {PermissionResolvable} [deny] The permissions to deny
|
|
163
|
-
* @property {OverwriteType} [type] The type of this OverwriteData
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Resolves an overwrite into {@link RawOverwriteData}.
|
|
168
|
-
* @param {OverwriteResolvable} overwrite The overwrite-like data to resolve
|
|
169
|
-
* @param {Guild} [guild] The guild to resolve from
|
|
170
|
-
* @returns {RawOverwriteData}
|
|
171
|
-
*/
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
172
93
|
static resolve(overwrite, guild) {
|
|
173
94
|
if (overwrite instanceof this) return overwrite.toJSON();
|
|
174
95
|
if (typeof overwrite.id === 'string' && overwrite.type in OverwriteType) {
|