@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,55 +7,30 @@ const Base = require('./Base');
|
|
|
7
7
|
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
|
8
8
|
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
* Represents an application command.
|
|
12
|
-
* @extends {Base}
|
|
13
|
-
*/
|
|
10
|
+
|
|
14
11
|
class ApplicationCommand extends Base {
|
|
15
12
|
constructor(client, data, guild, guildId) {
|
|
16
13
|
super(client);
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
* The command's id
|
|
20
|
-
* @type {Snowflake}
|
|
21
|
-
*/
|
|
15
|
+
|
|
22
16
|
this.id = data.id;
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
* The parent application's id
|
|
26
|
-
* @type {Snowflake}
|
|
27
|
-
*/
|
|
18
|
+
|
|
28
19
|
this.applicationId = data.application_id;
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
* The guild this command is part of
|
|
32
|
-
* @type {?Guild}
|
|
33
|
-
*/
|
|
21
|
+
|
|
34
22
|
this.guild = guild ?? null;
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
* The guild's id this command is part of, this may be non-null when `guild` is `null` if the command
|
|
38
|
-
* was fetched from the `ApplicationCommandManager`
|
|
39
|
-
* @type {?Snowflake}
|
|
40
|
-
*/
|
|
24
|
+
|
|
41
25
|
this.guildId = guild?.id ?? guildId ?? null;
|
|
42
26
|
|
|
43
|
-
|
|
44
|
-
* The manager for permissions of this command on its guild or arbitrary guilds when the command is global
|
|
45
|
-
* @type {ApplicationCommandPermissionsManager}
|
|
46
|
-
*/
|
|
27
|
+
|
|
47
28
|
this.permissions = new ApplicationCommandPermissionsManager(this);
|
|
48
29
|
|
|
49
|
-
|
|
50
|
-
* The type of this application command
|
|
51
|
-
* @type {ApplicationCommandType}
|
|
52
|
-
*/
|
|
30
|
+
|
|
53
31
|
this.type = data.type;
|
|
54
32
|
|
|
55
|
-
|
|
56
|
-
* Whether this command is age-restricted (18+)
|
|
57
|
-
* @type {boolean}
|
|
58
|
-
*/
|
|
33
|
+
|
|
59
34
|
this.nsfw = data.nsfw ?? false;
|
|
60
35
|
|
|
61
36
|
this._patch(data);
|
|
@@ -63,76 +38,52 @@ class ApplicationCommand extends Base {
|
|
|
63
38
|
|
|
64
39
|
_patch(data) {
|
|
65
40
|
if ('name' in data) {
|
|
66
|
-
|
|
67
|
-
* The name of this command
|
|
68
|
-
* @type {string}
|
|
69
|
-
*/
|
|
41
|
+
|
|
70
42
|
this.name = data.name;
|
|
71
43
|
}
|
|
72
44
|
|
|
73
45
|
if ('name_localizations' in data) {
|
|
74
|
-
|
|
75
|
-
* The name localizations for this command
|
|
76
|
-
* @type {?Object<Locale, string>}
|
|
77
|
-
*/
|
|
46
|
+
|
|
78
47
|
this.nameLocalizations = data.name_localizations;
|
|
79
48
|
} else {
|
|
80
49
|
this.nameLocalizations ??= null;
|
|
81
50
|
}
|
|
82
51
|
|
|
83
52
|
if ('name_localized' in data) {
|
|
84
|
-
|
|
85
|
-
* The localized name for this command
|
|
86
|
-
* @type {?string}
|
|
87
|
-
*/
|
|
53
|
+
|
|
88
54
|
this.nameLocalized = data.name_localized;
|
|
89
55
|
} else {
|
|
90
56
|
this.nameLocalized ??= null;
|
|
91
57
|
}
|
|
92
58
|
|
|
93
59
|
if ('description' in data) {
|
|
94
|
-
|
|
95
|
-
* The description of this command
|
|
96
|
-
* @type {string}
|
|
97
|
-
*/
|
|
60
|
+
|
|
98
61
|
this.description = data.description;
|
|
99
62
|
}
|
|
100
63
|
|
|
101
64
|
if ('description_localizations' in data) {
|
|
102
|
-
|
|
103
|
-
* The description localizations for this command
|
|
104
|
-
* @type {?Object<Locale, string>}
|
|
105
|
-
*/
|
|
65
|
+
|
|
106
66
|
this.descriptionLocalizations = data.description_localizations;
|
|
107
67
|
} else {
|
|
108
68
|
this.descriptionLocalizations ??= null;
|
|
109
69
|
}
|
|
110
70
|
|
|
111
71
|
if ('description_localized' in data) {
|
|
112
|
-
|
|
113
|
-
* The localized description for this command
|
|
114
|
-
* @type {?string}
|
|
115
|
-
*/
|
|
72
|
+
|
|
116
73
|
this.descriptionLocalized = data.description_localized;
|
|
117
74
|
} else {
|
|
118
75
|
this.descriptionLocalized ??= null;
|
|
119
76
|
}
|
|
120
77
|
|
|
121
78
|
if ('options' in data) {
|
|
122
|
-
|
|
123
|
-
* The options of this command
|
|
124
|
-
* @type {ApplicationCommandOption[]}
|
|
125
|
-
*/
|
|
79
|
+
|
|
126
80
|
this.options = data.options.map(o => this.constructor.transformOption(o, true));
|
|
127
81
|
} else {
|
|
128
82
|
this.options ??= [];
|
|
129
83
|
}
|
|
130
84
|
|
|
131
85
|
if ('default_member_permissions' in data) {
|
|
132
|
-
|
|
133
|
-
* The default bitfield used to determine whether this command be used in a guild
|
|
134
|
-
* @type {?Readonly<PermissionsBitField>}
|
|
135
|
-
*/
|
|
86
|
+
|
|
136
87
|
this.defaultMemberPermissions = data.default_member_permissions
|
|
137
88
|
? new PermissionsBitField(BigInt(data.default_member_permissions)).freeze()
|
|
138
89
|
: null;
|
|
@@ -141,225 +92,87 @@ class ApplicationCommand extends Base {
|
|
|
141
92
|
}
|
|
142
93
|
|
|
143
94
|
if ('dm_permission' in data) {
|
|
144
|
-
|
|
145
|
-
* Whether the command can be used in DMs
|
|
146
|
-
* <info>This property is always `null` on guild commands</info>
|
|
147
|
-
* @type {boolean|null}
|
|
148
|
-
*/
|
|
95
|
+
|
|
149
96
|
this.dmPermission = data.dm_permission;
|
|
150
97
|
} else {
|
|
151
98
|
this.dmPermission ??= null;
|
|
152
99
|
}
|
|
153
100
|
|
|
154
101
|
if ('version' in data) {
|
|
155
|
-
|
|
156
|
-
* Autoincrementing version identifier updated during substantial record changes
|
|
157
|
-
* @type {Snowflake}
|
|
158
|
-
*/
|
|
102
|
+
|
|
159
103
|
this.version = data.version;
|
|
160
104
|
}
|
|
161
105
|
}
|
|
162
106
|
|
|
163
|
-
|
|
164
|
-
* The timestamp the command was created at
|
|
165
|
-
* @type {number}
|
|
166
|
-
* @readonly
|
|
167
|
-
*/
|
|
107
|
+
|
|
168
108
|
get createdTimestamp() {
|
|
169
109
|
return DiscordSnowflake.timestampFrom(this.id);
|
|
170
110
|
}
|
|
171
111
|
|
|
172
|
-
|
|
173
|
-
* The time the command was created at
|
|
174
|
-
* @type {Date}
|
|
175
|
-
* @readonly
|
|
176
|
-
*/
|
|
112
|
+
|
|
177
113
|
get createdAt() {
|
|
178
114
|
return new Date(this.createdTimestamp);
|
|
179
115
|
}
|
|
180
116
|
|
|
181
|
-
|
|
182
|
-
* The manager that this command belongs to
|
|
183
|
-
* @type {ApplicationCommandManager}
|
|
184
|
-
* @readonly
|
|
185
|
-
*/
|
|
117
|
+
|
|
186
118
|
get manager() {
|
|
187
119
|
return (this.guild ?? this.client.application).commands;
|
|
188
120
|
}
|
|
189
121
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
* @property {boolean} [nsfw] Whether the command is age-restricted
|
|
198
|
-
* @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description,
|
|
199
|
-
* if type is {@link ApplicationCommandType.ChatInput}
|
|
200
|
-
* @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command
|
|
201
|
-
* @property {ApplicationCommandOptionData[]} [options] Options for the command
|
|
202
|
-
* @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
|
|
203
|
-
* a member needs in order to run the command
|
|
204
|
-
* @property {boolean} [dmPermission] Whether the command is enabled in DMs
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* An option for an application command or subcommand.
|
|
209
|
-
* <info>In addition to the listed properties, when used as a parameter,
|
|
210
|
-
* API style `snake_case` properties can be used for compatibility with generators like `@discordjs/builders`.</info>
|
|
211
|
-
* <warn>Note that providing a value for the `camelCase` counterpart for any `snake_case` property
|
|
212
|
-
* will discard the provided `snake_case` property.</warn>
|
|
213
|
-
* @typedef {Object} ApplicationCommandOptionData
|
|
214
|
-
* @property {ApplicationCommandOptionType} type The type of the option
|
|
215
|
-
* @property {string} name The name of the option
|
|
216
|
-
* @property {Object<Locale, string>} [nameLocalizations] The name localizations for the option
|
|
217
|
-
* @property {string} description The description of the option
|
|
218
|
-
* @property {Object<Locale, string>} [descriptionLocalizations] The description localizations for the option
|
|
219
|
-
* @property {boolean} [autocomplete] Whether the autocomplete interaction is enabled for a
|
|
220
|
-
* {@link ApplicationCommandOptionType.String}, {@link ApplicationCommandOptionType.Integer} or
|
|
221
|
-
* {@link ApplicationCommandOptionType.Number} option
|
|
222
|
-
* @property {boolean} [required] Whether the option is required
|
|
223
|
-
* @property {ApplicationCommandOptionChoiceData[]} [choices] The choices of the option for the user to pick from
|
|
224
|
-
* @property {ApplicationCommandOptionData[]} [options] Additional options if this option is a subcommand (group)
|
|
225
|
-
* @property {ChannelType[]} [channelTypes] When the option type is channel,
|
|
226
|
-
* the allowed types of channels that can be selected
|
|
227
|
-
* @property {number} [minValue] The minimum value for an {@link ApplicationCommandOptionType.Integer} or
|
|
228
|
-
* {@link ApplicationCommandOptionType.Number} option
|
|
229
|
-
* @property {number} [maxValue] The maximum value for an {@link ApplicationCommandOptionType.Integer} or
|
|
230
|
-
* {@link ApplicationCommandOptionType.Number} option
|
|
231
|
-
* @property {number} [minLength] The minimum length for an {@link ApplicationCommandOptionType.String} option
|
|
232
|
-
* (maximum of `6000`)
|
|
233
|
-
* @property {number} [maxLength] The maximum length for an {@link ApplicationCommandOptionType.String} option
|
|
234
|
-
* (maximum of `6000`)
|
|
235
|
-
*/
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* @typedef {Object} ApplicationCommandOptionChoiceData
|
|
239
|
-
* @property {string} name The name of the choice
|
|
240
|
-
* @property {Object<Locale, string>} [nameLocalizations] The localized names for this choice
|
|
241
|
-
* @property {string|number} value The value of the choice
|
|
242
|
-
*/
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Edits this application command.
|
|
246
|
-
* @param {Partial<ApplicationCommandData>} data The data to update the command with
|
|
247
|
-
* @returns {Promise<ApplicationCommand>}
|
|
248
|
-
* @example
|
|
249
|
-
* // Edit the description of this command
|
|
250
|
-
* command.edit({
|
|
251
|
-
* description: 'New description',
|
|
252
|
-
* })
|
|
253
|
-
* .then(console.log)
|
|
254
|
-
* .catch(console.error);
|
|
255
|
-
*/
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
256
129
|
edit(data) {
|
|
257
130
|
return this.manager.edit(this, data, this.guildId);
|
|
258
131
|
}
|
|
259
132
|
|
|
260
|
-
|
|
261
|
-
* Edits the name of this ApplicationCommand
|
|
262
|
-
* @param {string} name The new name of the command
|
|
263
|
-
* @returns {Promise<ApplicationCommand>}
|
|
264
|
-
*/
|
|
133
|
+
|
|
265
134
|
setName(name) {
|
|
266
135
|
return this.edit({ name });
|
|
267
136
|
}
|
|
268
137
|
|
|
269
|
-
|
|
270
|
-
* Edits the localized names of this ApplicationCommand
|
|
271
|
-
* @param {Object<Locale, string>} nameLocalizations The new localized names for the command
|
|
272
|
-
* @returns {Promise<ApplicationCommand>}
|
|
273
|
-
* @example
|
|
274
|
-
* // Edit the name localizations of this command
|
|
275
|
-
* command.setLocalizedNames({
|
|
276
|
-
* 'en-GB': 'test',
|
|
277
|
-
* 'pt-BR': 'teste',
|
|
278
|
-
* })
|
|
279
|
-
* .then(console.log)
|
|
280
|
-
* .catch(console.error)
|
|
281
|
-
*/
|
|
138
|
+
|
|
282
139
|
setNameLocalizations(nameLocalizations) {
|
|
283
140
|
return this.edit({ nameLocalizations });
|
|
284
141
|
}
|
|
285
142
|
|
|
286
|
-
|
|
287
|
-
* Edits the description of this ApplicationCommand
|
|
288
|
-
* @param {string} description The new description of the command
|
|
289
|
-
* @returns {Promise<ApplicationCommand>}
|
|
290
|
-
*/
|
|
143
|
+
|
|
291
144
|
setDescription(description) {
|
|
292
145
|
return this.edit({ description });
|
|
293
146
|
}
|
|
294
147
|
|
|
295
|
-
|
|
296
|
-
* Edits the localized descriptions of this ApplicationCommand
|
|
297
|
-
* @param {Object<Locale, string>} descriptionLocalizations The new localized descriptions for the command
|
|
298
|
-
* @returns {Promise<ApplicationCommand>}
|
|
299
|
-
* @example
|
|
300
|
-
* // Edit the description localizations of this command
|
|
301
|
-
* command.setDescriptionLocalizations({
|
|
302
|
-
* 'en-GB': 'A test command',
|
|
303
|
-
* 'pt-BR': 'Um comando de teste',
|
|
304
|
-
* })
|
|
305
|
-
* .then(console.log)
|
|
306
|
-
* .catch(console.error)
|
|
307
|
-
*/
|
|
148
|
+
|
|
308
149
|
setDescriptionLocalizations(descriptionLocalizations) {
|
|
309
150
|
return this.edit({ descriptionLocalizations });
|
|
310
151
|
}
|
|
311
152
|
|
|
312
|
-
|
|
313
|
-
* Edits the default member permissions of this ApplicationCommand
|
|
314
|
-
* @param {?PermissionResolvable} defaultMemberPermissions The default member permissions required to run this command
|
|
315
|
-
* @returns {Promise<ApplicationCommand>}
|
|
316
|
-
*/
|
|
153
|
+
|
|
317
154
|
setDefaultMemberPermissions(defaultMemberPermissions) {
|
|
318
155
|
return this.edit({ defaultMemberPermissions });
|
|
319
156
|
}
|
|
320
157
|
|
|
321
|
-
|
|
322
|
-
* Edits the DM permission of this ApplicationCommand
|
|
323
|
-
* @param {boolean} [dmPermission=true] Whether the command can be used in DMs
|
|
324
|
-
* @returns {Promise<ApplicationCommand>}
|
|
325
|
-
*/
|
|
158
|
+
|
|
326
159
|
setDMPermission(dmPermission = true) {
|
|
327
160
|
return this.edit({ dmPermission });
|
|
328
161
|
}
|
|
329
162
|
|
|
330
|
-
|
|
331
|
-
* Edits the options of this ApplicationCommand
|
|
332
|
-
* @param {ApplicationCommandOptionData[]} options The options to set for this command
|
|
333
|
-
* @returns {Promise<ApplicationCommand>}
|
|
334
|
-
*/
|
|
163
|
+
|
|
335
164
|
setOptions(options) {
|
|
336
165
|
return this.edit({ options });
|
|
337
166
|
}
|
|
338
167
|
|
|
339
|
-
|
|
340
|
-
* Deletes this command.
|
|
341
|
-
* @returns {Promise<ApplicationCommand>}
|
|
342
|
-
* @example
|
|
343
|
-
* // Delete this command
|
|
344
|
-
* command.delete()
|
|
345
|
-
* .then(console.log)
|
|
346
|
-
* .catch(console.error);
|
|
347
|
-
*/
|
|
168
|
+
|
|
348
169
|
delete() {
|
|
349
170
|
return this.manager.delete(this, this.guildId);
|
|
350
171
|
}
|
|
351
172
|
|
|
352
|
-
|
|
353
|
-
* Whether this command equals another command. It compares all properties, so for most operations
|
|
354
|
-
* it is advisable to just compare `command.id === command2.id` as it is much faster and is often
|
|
355
|
-
* what most users need.
|
|
356
|
-
* @param {ApplicationCommand|ApplicationCommandData|APIApplicationCommand} command The command to compare with
|
|
357
|
-
* @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
|
|
358
|
-
* order in the array <info>The client may not always respect this ordering!</info>
|
|
359
|
-
* @returns {boolean}
|
|
360
|
-
*/
|
|
173
|
+
|
|
361
174
|
equals(command, enforceOptionOrder = false) {
|
|
362
|
-
|
|
175
|
+
|
|
363
176
|
if (command.id && this.id !== command.id) return false;
|
|
364
177
|
|
|
365
178
|
let defaultMemberPermissions = null;
|
|
@@ -378,15 +191,15 @@ class ApplicationCommand extends Base {
|
|
|
378
191
|
: null;
|
|
379
192
|
}
|
|
380
193
|
|
|
381
|
-
|
|
194
|
+
|
|
382
195
|
if (
|
|
383
196
|
command.name !== this.name ||
|
|
384
197
|
('description' in command && command.description !== this.description) ||
|
|
385
198
|
('version' in command && command.version !== this.version) ||
|
|
386
199
|
(command.type && command.type !== this.type) ||
|
|
387
200
|
('nsfw' in command && command.nsfw !== this.nsfw) ||
|
|
388
|
-
|
|
389
|
-
|
|
201
|
+
|
|
202
|
+
|
|
390
203
|
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
|
|
391
204
|
defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
|
|
392
205
|
(dmPermission !== undefined && dmPermission !== this.dmPermission) ||
|
|
@@ -405,16 +218,7 @@ class ApplicationCommand extends Base {
|
|
|
405
218
|
return true;
|
|
406
219
|
}
|
|
407
220
|
|
|
408
|
-
|
|
409
|
-
* Recursively checks that all options for an {@link ApplicationCommand} are equal to the provided options.
|
|
410
|
-
* In most cases it is better to compare using {@link ApplicationCommand#equals}
|
|
411
|
-
* @param {ApplicationCommandOptionData[]} existing The options on the existing command,
|
|
412
|
-
* should be {@link ApplicationCommand#options}
|
|
413
|
-
* @param {ApplicationCommandOptionData[]|APIApplicationCommandOption[]} options The options to compare against
|
|
414
|
-
* @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
|
|
415
|
-
* order in the array <info>The client may not always respect this ordering!</info>
|
|
416
|
-
* @returns {boolean}
|
|
417
|
-
*/
|
|
221
|
+
|
|
418
222
|
static optionsEqual(existing, options, enforceOptionOrder = false) {
|
|
419
223
|
if (existing.length !== options.length) return false;
|
|
420
224
|
if (enforceOptionOrder) {
|
|
@@ -428,17 +232,7 @@ class ApplicationCommand extends Base {
|
|
|
428
232
|
return true;
|
|
429
233
|
}
|
|
430
234
|
|
|
431
|
-
|
|
432
|
-
* Checks that an option for an {@link ApplicationCommand} is equal to the provided option
|
|
433
|
-
* In most cases it is better to compare using {@link ApplicationCommand#equals}
|
|
434
|
-
* @param {ApplicationCommandOptionData} existing The option on the existing command,
|
|
435
|
-
* should be from {@link ApplicationCommand#options}
|
|
436
|
-
* @param {ApplicationCommandOptionData|APIApplicationCommandOption} option The option to compare against
|
|
437
|
-
* @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options or choices are in the same
|
|
438
|
-
* order in their array <info>The client may not always respect this ordering!</info>
|
|
439
|
-
* @returns {boolean}
|
|
440
|
-
* @private
|
|
441
|
-
*/
|
|
235
|
+
|
|
442
236
|
static _optionEquals(existing, option, enforceOptionOrder = false) {
|
|
443
237
|
if (
|
|
444
238
|
option.name !== existing.name ||
|
|
@@ -502,50 +296,11 @@ class ApplicationCommand extends Base {
|
|
|
502
296
|
return true;
|
|
503
297
|
}
|
|
504
298
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
* @property {Object<Locale, string>} [nameLocalizations] The localizations for the option name
|
|
511
|
-
* @property {string} [nameLocalized] The localized name for this option
|
|
512
|
-
* @property {string} description The description of the option
|
|
513
|
-
* @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the option description
|
|
514
|
-
* @property {string} [descriptionLocalized] The localized description for this option
|
|
515
|
-
* @property {boolean} [required] Whether the option is required
|
|
516
|
-
* @property {boolean} [autocomplete] Whether the autocomplete interaction is enabled for a
|
|
517
|
-
* {@link ApplicationCommandOptionType.String}, {@link ApplicationCommandOptionType.Integer} or
|
|
518
|
-
* {@link ApplicationCommandOptionType.Number} option
|
|
519
|
-
* @property {ApplicationCommandOptionChoice[]} [choices] The choices of the option for the user to pick from
|
|
520
|
-
* @property {ApplicationCommandOption[]} [options] Additional options if this option is a subcommand (group)
|
|
521
|
-
* @property {ApplicationCommandOptionAllowedChannelTypes[]} [channelTypes] When the option type is channel,
|
|
522
|
-
* the allowed types of channels that can be selected
|
|
523
|
-
* @property {number} [minValue] The minimum value for an {@link ApplicationCommandOptionType.Integer} or
|
|
524
|
-
* {@link ApplicationCommandOptionType.Number} option
|
|
525
|
-
* @property {number} [maxValue] The maximum value for an {@link ApplicationCommandOptionType.Integer} or
|
|
526
|
-
* {@link ApplicationCommandOptionType.Number} option
|
|
527
|
-
* @property {number} [minLength] The minimum length for an {@link ApplicationCommandOptionType.String} option
|
|
528
|
-
* (maximum of `6000`)
|
|
529
|
-
* @property {number} [maxLength] The maximum length for an {@link ApplicationCommandOptionType.String} option
|
|
530
|
-
* (maximum of `6000`)
|
|
531
|
-
*/
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* A choice for an application command option.
|
|
535
|
-
* @typedef {Object} ApplicationCommandOptionChoice
|
|
536
|
-
* @property {string} name The name of the choice
|
|
537
|
-
* @property {?string} nameLocalized The localized name of the choice in the provided locale, if any
|
|
538
|
-
* @property {?Object<string, string>} [nameLocalizations] The localized names for this choice
|
|
539
|
-
* @property {string|number} value The value of the choice
|
|
540
|
-
*/
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* Transforms an {@link ApplicationCommandOptionData} object into something that can be used with the API.
|
|
544
|
-
* @param {ApplicationCommandOptionData|ApplicationCommandOption} option The option to transform
|
|
545
|
-
* @param {boolean} [received] Whether this option has been received from Discord
|
|
546
|
-
* @returns {APIApplicationCommandOption}
|
|
547
|
-
* @private
|
|
548
|
-
*/
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
549
304
|
static transformOption(option, received) {
|
|
550
305
|
const channelTypesKey = received ? 'channelTypes' : 'channel_types';
|
|
551
306
|
const minValueKey = received ? 'minValue' : 'min_value';
|
|
@@ -589,18 +344,9 @@ class ApplicationCommand extends Base {
|
|
|
589
344
|
|
|
590
345
|
module.exports = ApplicationCommand;
|
|
591
346
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* @external APIApplicationCommandOption
|
|
600
|
-
* @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure}
|
|
601
|
-
*/
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* @external ApplicationCommandOptionAllowedChannelTypes
|
|
605
|
-
* @see {@link https://discord.js.org/docs/packages/builders/stable/ApplicationCommandOptionAllowedChannelTypes:TypeAlias}
|
|
606
|
-
*/
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
@@ -1,44 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* Role connection metadata object for an application.
|
|
5
|
-
*/
|
|
3
|
+
|
|
6
4
|
class ApplicationRoleConnectionMetadata {
|
|
7
5
|
constructor(data) {
|
|
8
|
-
|
|
9
|
-
* The name of this metadata field
|
|
10
|
-
* @type {string}
|
|
11
|
-
*/
|
|
6
|
+
|
|
12
7
|
this.name = data.name;
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
* The name localizations for this metadata field
|
|
16
|
-
* @type {?Object<Locale, string>}
|
|
17
|
-
*/
|
|
9
|
+
|
|
18
10
|
this.nameLocalizations = data.name_localizations ?? null;
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
* The description of this metadata field
|
|
22
|
-
* @type {string}
|
|
23
|
-
*/
|
|
12
|
+
|
|
24
13
|
this.description = data.description;
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
* The description localizations for this metadata field
|
|
28
|
-
* @type {?Object<Locale, string>}
|
|
29
|
-
*/
|
|
15
|
+
|
|
30
16
|
this.descriptionLocalizations = data.description_localizations ?? null;
|
|
31
17
|
|
|
32
|
-
|
|
33
|
-
* The dictionary key for this metadata field
|
|
34
|
-
* @type {string}
|
|
35
|
-
*/
|
|
18
|
+
|
|
36
19
|
this.key = data.key;
|
|
37
20
|
|
|
38
|
-
|
|
39
|
-
* The type of this metadata field
|
|
40
|
-
* @type {ApplicationRoleConnectionMetadataType}
|
|
41
|
-
*/
|
|
21
|
+
|
|
42
22
|
this.type = data.type;
|
|
43
23
|
}
|
|
44
24
|
}
|