lolka.js 0.1.4 → 0.2.0
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 +6 -6
- package/package.json +21 -52
- package/src/client/BaseClient.js +120 -0
- package/src/client/Client.js +147 -446
- package/src/client/WebhookClient.js +103 -0
- package/src/client/actions/Action.js +3 -4
- package/src/client/actions/ActionsManager.js +65 -55
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
- package/src/client/actions/AutoModerationActionExecution.js +26 -0
- package/src/client/actions/AutoModerationRuleCreate.js +27 -0
- package/src/client/actions/AutoModerationRuleDelete.js +31 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +29 -0
- package/src/client/actions/ChannelCreate.js +3 -5
- package/src/client/actions/ChannelDelete.js +3 -4
- package/src/client/actions/ChannelUpdate.js +3 -3
- package/src/client/actions/EntitlementCreate.js +23 -0
- package/src/client/actions/EntitlementDelete.js +27 -0
- package/src/client/actions/EntitlementUpdate.js +25 -0
- package/src/client/actions/GuildAuditLogEntryCreate.js +29 -0
- package/src/client/actions/GuildBanAdd.js +20 -0
- package/src/client/actions/GuildBanRemove.js +25 -0
- package/src/client/actions/GuildChannelsPositionUpdate.js +3 -3
- package/src/client/actions/GuildDelete.js +44 -0
- package/src/client/actions/GuildEmojiCreate.js +3 -4
- package/src/client/actions/GuildEmojiDelete.js +3 -4
- package/src/client/actions/GuildEmojiUpdate.js +3 -4
- package/src/client/actions/GuildEmojisUpdate.js +2 -2
- package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
- package/src/client/actions/GuildMemberRemove.js +6 -8
- package/src/client/actions/GuildMemberUpdate.js +6 -7
- package/src/client/actions/GuildRoleCreate.js +4 -6
- package/src/client/actions/GuildRoleDelete.js +3 -4
- package/src/client/actions/GuildRoleUpdate.js +39 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +3 -3
- package/src/client/actions/GuildScheduledEventCreate.js +27 -0
- package/src/client/actions/GuildScheduledEventDelete.js +3 -4
- package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
- package/src/client/actions/GuildScheduledEventUserAdd.js +3 -4
- package/src/client/actions/GuildScheduledEventUserRemove.js +3 -4
- package/src/client/actions/GuildSoundboardSoundDelete.js +3 -4
- package/src/client/actions/GuildStickerCreate.js +3 -4
- package/src/client/actions/GuildStickerDelete.js +3 -4
- package/src/client/actions/GuildStickerUpdate.js +3 -4
- package/src/client/actions/GuildStickersUpdate.js +2 -2
- package/src/client/actions/GuildUpdate.js +3 -4
- package/src/client/actions/InteractionCreate.js +15 -18
- package/src/client/actions/InviteCreate.js +27 -0
- package/src/client/actions/InviteDelete.js +29 -0
- package/src/client/actions/MessageCreate.js +3 -4
- package/src/client/actions/MessageDelete.js +3 -4
- package/src/client/actions/MessageDeleteBulk.js +3 -5
- package/src/client/actions/MessagePollVoteAdd.js +3 -4
- package/src/client/actions/MessagePollVoteRemove.js +3 -4
- package/src/client/actions/MessageReactionAdd.js +5 -7
- package/src/client/actions/MessageReactionRemove.js +4 -5
- package/src/client/actions/MessageReactionRemoveAll.js +4 -5
- package/src/client/actions/MessageReactionRemoveEmoji.js +4 -5
- package/src/client/actions/MessageUpdate.js +2 -2
- package/src/client/actions/PresenceUpdate.js +45 -0
- package/src/client/actions/StageInstanceCreate.js +3 -4
- package/src/client/actions/StageInstanceDelete.js +3 -4
- package/src/client/actions/StageInstanceUpdate.js +3 -4
- package/src/client/actions/ThreadCreate.js +3 -5
- package/src/client/actions/ThreadDelete.js +26 -0
- package/src/client/actions/ThreadListSync.js +60 -0
- package/src/client/actions/ThreadMemberUpdate.js +30 -0
- package/src/client/actions/ThreadMembersUpdate.js +3 -5
- package/src/client/actions/TypingStart.js +5 -6
- package/src/client/actions/UserUpdate.js +3 -4
- package/src/client/actions/VoiceStateUpdate.js +43 -0
- package/src/client/actions/WebhooksUpdate.js +37 -0
- package/src/client/voice/ClientVoiceManager.js +6 -10
- package/src/client/websocket/WebSocketManager.js +407 -0
- package/src/client/websocket/WebSocketShard.js +234 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +2 -27
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +2 -15
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +2 -16
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +2 -19
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +2 -18
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +1 -2
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -2
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.js +2 -12
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.js +2 -16
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.js +2 -14
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +2 -17
- package/src/client/websocket/handlers/GUILD_BAN_ADD.js +2 -13
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +2 -18
- package/src/client/websocket/handlers/GUILD_CREATE.js +5 -7
- package/src/client/websocket/handlers/GUILD_DELETE.js +2 -34
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +2 -13
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +1 -3
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +11 -9
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +2 -2
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +2 -2
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +2 -19
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +2 -15
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +2 -17
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +1 -2
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +1 -2
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +1 -2
- package/src/client/websocket/handlers/INVITE_CREATE.js +2 -18
- package/src/client/websocket/handlers/INVITE_DELETE.js +2 -21
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -2
- package/src/client/websocket/handlers/PRESENCE_UPDATE.js +2 -40
- package/src/client/websocket/handlers/RATE_LIMITED.js +2 -1
- package/src/client/websocket/handlers/READY.js +5 -8
- package/src/client/websocket/handlers/RESUMED.js +14 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.js +1 -2
- package/src/client/websocket/handlers/THREAD_DELETE.js +2 -15
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +2 -49
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +2 -23
- package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -2
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +2 -3
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +3 -30
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +2 -35
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +2 -14
- package/src/client/websocket/handlers/index.js +75 -74
- package/src/errors/DJSError.js +7 -7
- package/src/errors/ErrorCodes.js +134 -58
- package/src/errors/Messages.js +143 -115
- package/src/errors/index.js +3 -5
- package/src/index.js +226 -234
- package/src/managers/ApplicationCommandManager.js +24 -60
- package/src/managers/ApplicationCommandPermissionsManager.js +33 -57
- package/src/managers/ApplicationEmojiManager.js +8 -18
- package/src/managers/AutoModerationRuleManager.js +6 -24
- package/src/managers/BaseGuildEmojiManager.js +85 -0
- package/src/managers/BaseManager.js +1 -3
- package/src/managers/CachedManager.js +8 -12
- package/src/managers/CategoryChannelChildManager.js +4 -10
- package/src/managers/ChannelManager.js +8 -70
- package/src/managers/DMMessageManager.js +2 -4
- package/src/managers/DataManager.js +5 -10
- package/src/managers/EntitlementManager.js +8 -19
- package/src/managers/GuildApplicationCommandManager.js +3 -6
- package/src/managers/GuildBanManager.js +52 -27
- package/src/managers/GuildChannelManager.js +54 -91
- package/src/managers/GuildEmojiManager.js +18 -108
- package/src/managers/GuildEmojiRoleManager.js +14 -24
- package/src/managers/GuildForumThreadManager.js +5 -10
- package/src/managers/GuildInviteManager.js +27 -51
- package/src/managers/GuildManager.js +185 -45
- package/src/managers/GuildMemberManager.js +105 -89
- package/src/managers/GuildMemberRoleManager.js +14 -29
- package/src/managers/GuildMessageManager.js +2 -20
- package/src/managers/GuildScheduledEventManager.js +13 -31
- package/src/managers/GuildSoundboardSoundManager.js +5 -17
- package/src/managers/GuildStickerManager.js +21 -34
- package/src/managers/GuildTextThreadManager.js +5 -9
- package/src/managers/MessageManager.js +77 -64
- package/src/managers/PartialGroupDMMessageManager.js +2 -4
- package/src/managers/PermissionOverwriteManager.js +15 -26
- package/src/managers/PollAnswerVoterManager.js +2 -14
- package/src/managers/PresenceManager.js +6 -11
- package/src/managers/ReactionManager.js +6 -13
- package/src/managers/ReactionUserManager.js +4 -11
- package/src/managers/RoleManager.js +74 -76
- package/src/managers/StageInstanceManager.js +8 -18
- package/src/managers/SubscriptionManager.js +4 -9
- package/src/managers/ThreadManager.js +13 -33
- package/src/managers/ThreadMemberManager.js +34 -27
- package/src/managers/UserManager.js +34 -32
- package/src/managers/VoiceStateManager.js +4 -9
- package/src/sharding/Shard.js +40 -64
- package/src/sharding/ShardClientUtil.js +60 -60
- package/src/sharding/ShardingManager.js +30 -89
- package/src/structures/ActionRow.js +18 -6
- package/src/structures/ActionRowBuilder.js +35 -0
- package/src/structures/AnonymousGuild.js +10 -14
- package/src/structures/ApplicationCommand.js +49 -67
- package/src/structures/ApplicationEmoji.js +5 -22
- package/src/structures/ApplicationRoleConnectionMetadata.js +0 -6
- package/src/structures/Attachment.js +7 -25
- package/src/structures/AttachmentBuilder.js +111 -0
- package/src/structures/AutoModerationActionExecution.js +2 -17
- package/src/structures/AutoModerationRule.js +17 -46
- package/src/structures/AutocompleteInteraction.js +4 -14
- package/src/structures/Base.js +2 -4
- package/src/structures/BaseChannel.js +4 -21
- package/src/structures/BaseGuild.js +7 -19
- package/src/structures/BaseGuildEmoji.js +13 -13
- package/src/structures/BaseGuildTextChannel.js +16 -45
- package/src/structures/BaseGuildVoiceChannel.js +12 -43
- package/src/structures/BaseInteraction.js +25 -54
- package/src/structures/BaseSelectMenuComponent.js +2 -8
- package/src/structures/ButtonBuilder.js +44 -0
- package/src/structures/ButtonComponent.js +2 -9
- package/src/structures/ButtonInteraction.js +2 -3
- package/src/structures/CategoryChannel.js +3 -8
- package/src/structures/ChannelSelectMenuBuilder.js +31 -0
- package/src/structures/ChannelSelectMenuComponent.js +2 -4
- package/src/structures/ChannelSelectMenuInteraction.js +2 -5
- package/src/structures/ChatInputCommandInteraction.js +4 -7
- package/src/structures/ClientApplication.js +12 -60
- package/src/structures/ClientPresence.js +10 -15
- package/src/structures/ClientUser.js +19 -36
- package/src/structures/CommandInteraction.js +7 -27
- package/src/structures/CommandInteractionOptionResolver.js +8 -36
- package/src/structures/Component.js +1 -7
- package/src/structures/ContainerComponent.js +3 -9
- package/src/structures/ContextMenuCommandInteraction.js +5 -9
- package/src/structures/DMChannel.js +15 -34
- package/src/structures/DirectoryChannel.js +2 -6
- package/src/structures/Embed.js +2 -19
- package/src/structures/EmbedBuilder.js +50 -0
- package/src/structures/Emoji.js +19 -19
- package/src/structures/Entitlement.js +2 -22
- package/src/structures/FileComponent.js +3 -7
- package/src/structures/ForumChannel.js +3 -6
- package/src/structures/Guild.js +131 -187
- package/src/structures/GuildAuditLogs.js +6 -12
- package/src/structures/GuildAuditLogsEntry.js +63 -88
- package/src/structures/GuildBan.js +3 -9
- package/src/structures/GuildChannel.js +33 -68
- package/src/structures/GuildEmoji.js +7 -19
- package/src/structures/GuildMember.js +58 -107
- package/src/structures/GuildOnboarding.js +2 -9
- package/src/structures/GuildOnboardingPrompt.js +2 -12
- package/src/structures/GuildOnboardingPromptOption.js +2 -12
- package/src/structures/GuildPreview.js +21 -30
- package/src/structures/GuildPreviewEmoji.js +2 -5
- package/src/structures/GuildScheduledEvent.js +19 -59
- package/src/structures/GuildTemplate.js +45 -24
- package/src/structures/Integration.js +7 -30
- package/src/structures/IntegrationApplication.js +12 -9
- package/src/structures/InteractionCallback.js +1 -10
- package/src/structures/InteractionCallbackResource.js +2 -7
- package/src/structures/InteractionCallbackResponse.js +3 -6
- package/src/structures/InteractionCollector.js +36 -23
- package/src/structures/InteractionResponse.js +102 -0
- package/src/structures/InteractionWebhook.js +6 -14
- package/src/structures/Invite.js +341 -0
- package/src/structures/InviteGuild.js +4 -6
- package/src/structures/InviteStageInstance.js +87 -0
- package/src/structures/LabelComponent.js +3 -3
- package/src/structures/MediaChannel.js +2 -3
- package/src/structures/MediaGalleryComponent.js +3 -6
- package/src/structures/MediaGalleryItem.js +2 -7
- package/src/structures/MentionableSelectMenuBuilder.js +32 -0
- package/src/structures/MentionableSelectMenuComponent.js +2 -3
- package/src/structures/MentionableSelectMenuInteraction.js +3 -8
- package/src/structures/Message.js +100 -169
- package/src/structures/MessageCollector.js +5 -16
- package/src/structures/MessageComponentInteraction.js +14 -34
- package/src/structures/MessageContextMenuCommandInteraction.js +2 -4
- package/src/structures/MessageMentions.js +4 -30
- package/src/structures/MessagePayload.js +90 -92
- package/src/structures/MessageReaction.js +17 -31
- package/src/structures/ModalBuilder.js +36 -0
- package/src/structures/{ModalComponentResolver.js → ModalSubmitFields.js} +31 -37
- package/src/structures/ModalSubmitInteraction.js +55 -54
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +3 -6
- package/src/structures/PartialGroupDMChannel.js +11 -23
- package/src/structures/PermissionOverwrites.js +25 -47
- package/src/structures/Poll.js +4 -19
- package/src/structures/PollAnswer.js +29 -13
- package/src/structures/Presence.js +13 -57
- package/src/structures/PrimaryEntryPointCommandInteraction.js +2 -3
- package/src/structures/ReactionCollector.js +4 -21
- package/src/structures/ReactionEmoji.js +3 -5
- package/src/structures/Role.js +48 -65
- package/src/structures/RoleSelectMenuBuilder.js +31 -0
- package/src/structures/RoleSelectMenuComponent.js +2 -3
- package/src/structures/RoleSelectMenuInteraction.js +2 -5
- package/src/structures/SKU.js +2 -9
- package/src/structures/SectionComponent.js +3 -7
- package/src/structures/SelectMenuBuilder.js +26 -0
- package/src/structures/SelectMenuComponent.js +26 -0
- package/src/structures/SelectMenuInteraction.js +26 -0
- package/src/structures/SelectMenuOptionBuilder.js +26 -0
- package/src/structures/SeparatorComponent.js +2 -5
- package/src/structures/SoundboardSound.js +2 -18
- package/src/structures/StageChannel.js +4 -13
- package/src/structures/StageInstance.js +16 -19
- package/src/structures/Sticker.js +4 -28
- package/src/structures/StickerPack.js +4 -16
- package/src/structures/StringSelectMenuBuilder.js +79 -0
- package/src/structures/StringSelectMenuComponent.js +2 -4
- package/src/structures/StringSelectMenuInteraction.js +2 -4
- package/src/structures/StringSelectMenuOptionBuilder.js +49 -0
- package/src/structures/Subscription.js +1 -15
- package/src/structures/Team.js +7 -16
- package/src/structures/TeamMember.js +15 -9
- package/src/structures/TextChannel.js +3 -6
- package/src/structures/TextDisplayComponent.js +2 -4
- package/src/structures/TextInputBuilder.js +31 -0
- package/src/structures/TextInputComponent.js +2 -5
- package/src/structures/ThreadChannel.js +35 -85
- package/src/structures/ThreadMember.js +12 -17
- package/src/structures/ThreadOnlyChannel.js +15 -36
- package/src/structures/ThumbnailComponent.js +3 -8
- package/src/structures/Typing.js +2 -10
- package/src/structures/UnfurledMediaItem.js +2 -5
- package/src/structures/User.js +68 -60
- package/src/structures/UserContextMenuCommandInteraction.js +2 -5
- package/src/structures/UserSelectMenuBuilder.js +31 -0
- package/src/structures/UserSelectMenuComponent.js +2 -3
- package/src/structures/UserSelectMenuInteraction.js +3 -7
- package/src/structures/VoiceChannel.js +4 -11
- package/src/structures/VoiceChannelEffect.js +2 -12
- package/src/structures/VoiceRegion.js +2 -7
- package/src/structures/VoiceState.js +10 -36
- package/src/structures/Webhook.js +37 -65
- package/src/structures/WelcomeChannel.js +5 -12
- package/src/structures/WelcomeScreen.js +3 -8
- package/src/structures/Widget.js +3 -13
- package/src/structures/WidgetMember.js +2 -17
- package/src/structures/interfaces/Application.js +10 -19
- package/src/structures/interfaces/Collector.js +12 -45
- package/src/structures/interfaces/InteractionResponses.js +152 -43
- package/src/structures/interfaces/TextBasedChannel.js +99 -83
- package/src/util/APITypes.js +16 -30
- package/src/util/ActivityFlagsBitField.js +2 -5
- package/src/util/ApplicationFlagsBitField.js +6 -11
- package/src/util/AttachmentFlagsBitField.js +2 -5
- package/src/util/BitField.js +8 -27
- package/src/util/ChannelFlagsBitField.js +6 -11
- package/src/util/Channels.js +61 -73
- package/src/util/Colors.js +43 -43
- package/src/util/Components.js +82 -61
- package/src/util/Constants.js +124 -94
- package/src/util/DataResolver.js +17 -36
- package/src/util/Enums.js +1 -2
- package/src/util/Events.js +14 -3
- package/src/util/Formatters.js +413 -0
- package/src/util/GuildMemberFlagsBitField.js +5 -9
- package/src/util/IntentsBitField.js +6 -10
- package/src/util/InviteFlagsBitField.js +1 -2
- package/src/util/LimitedCollection.js +6 -13
- package/src/util/LolkaSnowflake.js +14 -1
- package/src/util/MessageFlagsBitField.js +6 -11
- package/src/util/Options.js +57 -35
- package/src/util/Partials.js +4 -5
- package/src/util/PermissionsBitField.js +8 -21
- package/src/util/RoleFlagsBitField.js +2 -5
- package/src/util/SKUFlagsBitField.js +1 -4
- package/src/util/ShardEvents.js +3 -1
- package/src/util/Status.js +21 -5
- package/src/util/Sweepers.js +13 -59
- package/src/util/SystemChannelFlagsBitField.js +6 -11
- package/src/util/ThreadMemberFlagsBitField.js +2 -6
- package/src/util/Transformers.js +18 -17
- package/src/util/UserFlagsBitField.js +2 -6
- package/src/util/Util.js +97 -148
- package/src/util/WebSocketShardEvents.js +25 -0
- package/typings/index.d.mts +2394 -1771
- package/typings/index.d.ts +2394 -1771
- package/typings/rawDataTypes.d.ts +211 -0
- package/src/structures/ActivityInstance.js +0 -52
- package/src/structures/ActivityLocation.js +0 -65
- package/src/structures/AnnouncementChannel.js +0 -29
- package/src/structures/AuthorizingIntegrationOwners.js +0 -64
- package/src/structures/BaseInvite.js +0 -187
- package/src/structures/GroupDMInvite.js +0 -37
- package/src/structures/GuildInvite.js +0 -223
- package/src/util/Invites.js +0 -31
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { Routes } = require('discord-api-types/v10');
|
|
4
|
-
const
|
|
5
|
-
const {
|
|
4
|
+
const User = require('./User');
|
|
5
|
+
const { resolveImage } = require('../util/DataResolver');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Represents the logged in client's Discord user.
|
|
9
|
-
*
|
|
10
9
|
* @extends {User}
|
|
11
10
|
*/
|
|
12
11
|
class ClientUser extends User {
|
|
@@ -16,7 +15,6 @@ class ClientUser extends User {
|
|
|
16
15
|
if ('verified' in data) {
|
|
17
16
|
/**
|
|
18
17
|
* Whether or not this account has been verified
|
|
19
|
-
*
|
|
20
18
|
* @type {boolean}
|
|
21
19
|
*/
|
|
22
20
|
this.verified = data.verified;
|
|
@@ -25,7 +23,6 @@ class ClientUser extends User {
|
|
|
25
23
|
if ('mfa_enabled' in data) {
|
|
26
24
|
/**
|
|
27
25
|
* If the bot's {@link ClientApplication#owner Owner} has MFA enabled on their account
|
|
28
|
-
*
|
|
29
26
|
* @type {?boolean}
|
|
30
27
|
*/
|
|
31
28
|
this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null;
|
|
@@ -38,7 +35,6 @@ class ClientUser extends User {
|
|
|
38
35
|
|
|
39
36
|
/**
|
|
40
37
|
* Represents the client user's presence
|
|
41
|
-
*
|
|
42
38
|
* @type {ClientPresence}
|
|
43
39
|
* @readonly
|
|
44
40
|
*/
|
|
@@ -48,7 +44,6 @@ class ClientUser extends User {
|
|
|
48
44
|
|
|
49
45
|
/**
|
|
50
46
|
* Data used to edit the logged in client
|
|
51
|
-
*
|
|
52
47
|
* @typedef {Object} ClientUserEditOptions
|
|
53
48
|
* @property {string} [username] The new username
|
|
54
49
|
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] The new avatar
|
|
@@ -57,7 +52,6 @@ class ClientUser extends User {
|
|
|
57
52
|
|
|
58
53
|
/**
|
|
59
54
|
* Edits the logged in client.
|
|
60
|
-
*
|
|
61
55
|
* @param {ClientUserEditOptions} options The options to provide
|
|
62
56
|
* @returns {Promise<ClientUser>}
|
|
63
57
|
*/
|
|
@@ -78,7 +72,6 @@ class ClientUser extends User {
|
|
|
78
72
|
* Sets the username of the logged in client.
|
|
79
73
|
* <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
|
|
80
74
|
* every hour. Use this sparingly!</info>
|
|
81
|
-
*
|
|
82
75
|
* @param {string} username The new username
|
|
83
76
|
* @returns {Promise<ClientUser>}
|
|
84
77
|
* @example
|
|
@@ -87,13 +80,12 @@ class ClientUser extends User {
|
|
|
87
80
|
* .then(user => console.log(`My new username is ${user.username}`))
|
|
88
81
|
* .catch(console.error);
|
|
89
82
|
*/
|
|
90
|
-
|
|
83
|
+
setUsername(username) {
|
|
91
84
|
return this.edit({ username });
|
|
92
85
|
}
|
|
93
86
|
|
|
94
87
|
/**
|
|
95
88
|
* Sets the avatar of the logged in client.
|
|
96
|
-
*
|
|
97
89
|
* @param {?(BufferResolvable|Base64Resolvable)} avatar The new avatar
|
|
98
90
|
* @returns {Promise<ClientUser>}
|
|
99
91
|
* @example
|
|
@@ -102,13 +94,12 @@ class ClientUser extends User {
|
|
|
102
94
|
* .then(user => console.log(`New avatar set!`))
|
|
103
95
|
* .catch(console.error);
|
|
104
96
|
*/
|
|
105
|
-
|
|
97
|
+
setAvatar(avatar) {
|
|
106
98
|
return this.edit({ avatar });
|
|
107
99
|
}
|
|
108
100
|
|
|
109
101
|
/**
|
|
110
102
|
* Sets the banner of the logged in client.
|
|
111
|
-
*
|
|
112
103
|
* @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
|
|
113
104
|
* @returns {Promise<ClientUser>}
|
|
114
105
|
* @example
|
|
@@ -117,13 +108,12 @@ class ClientUser extends User {
|
|
|
117
108
|
* .then(user => console.log(`New banner set!`))
|
|
118
109
|
* .catch(console.error);
|
|
119
110
|
*/
|
|
120
|
-
|
|
111
|
+
setBanner(banner) {
|
|
121
112
|
return this.edit({ banner });
|
|
122
113
|
}
|
|
123
114
|
|
|
124
115
|
/**
|
|
125
116
|
* Options for setting activities
|
|
126
|
-
*
|
|
127
117
|
* @typedef {Object} ActivitiesOptions
|
|
128
118
|
* @property {string} name Name of the activity
|
|
129
119
|
* @property {string} [state] State of the activity
|
|
@@ -133,7 +123,6 @@ class ClientUser extends User {
|
|
|
133
123
|
|
|
134
124
|
/**
|
|
135
125
|
* Data resembling a raw Discord presence.
|
|
136
|
-
*
|
|
137
126
|
* @typedef {Object} PresenceData
|
|
138
127
|
* @property {PresenceStatusData} [status] Status of the user
|
|
139
128
|
* @property {boolean} [afk] Whether the user is AFK
|
|
@@ -143,44 +132,40 @@ class ClientUser extends User {
|
|
|
143
132
|
|
|
144
133
|
/**
|
|
145
134
|
* Sets the full presence of the client user.
|
|
146
|
-
*
|
|
147
135
|
* @param {PresenceData} data Data for the presence
|
|
148
|
-
* @returns {
|
|
136
|
+
* @returns {ClientPresence}
|
|
149
137
|
* @example
|
|
150
138
|
* // Set the client user's presence
|
|
151
139
|
* client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });
|
|
152
140
|
*/
|
|
153
|
-
|
|
141
|
+
setPresence(data) {
|
|
154
142
|
return this.client.presence.set(data);
|
|
155
143
|
}
|
|
156
144
|
|
|
157
145
|
/**
|
|
158
146
|
* A user's status. Must be one of:
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
147
|
+
* * `online`
|
|
148
|
+
* * `idle`
|
|
149
|
+
* * `invisible`
|
|
150
|
+
* * `dnd` (do not disturb)
|
|
164
151
|
* @typedef {string} PresenceStatusData
|
|
165
152
|
*/
|
|
166
153
|
|
|
167
154
|
/**
|
|
168
155
|
* Sets the status of the client user.
|
|
169
|
-
*
|
|
170
156
|
* @param {PresenceStatusData} status Status to change to
|
|
171
157
|
* @param {number|number[]} [shardId] Shard id(s) to have the activity set on
|
|
172
|
-
* @returns {
|
|
158
|
+
* @returns {ClientPresence}
|
|
173
159
|
* @example
|
|
174
160
|
* // Set the client user's status
|
|
175
161
|
* client.user.setStatus('idle');
|
|
176
162
|
*/
|
|
177
|
-
|
|
163
|
+
setStatus(status, shardId) {
|
|
178
164
|
return this.setPresence({ status, shardId });
|
|
179
165
|
}
|
|
180
166
|
|
|
181
167
|
/**
|
|
182
168
|
* Options for setting an activity.
|
|
183
|
-
*
|
|
184
169
|
* @typedef {Object} ActivityOptions
|
|
185
170
|
* @property {string} name Name of the activity
|
|
186
171
|
* @property {string} [state] State of the activity
|
|
@@ -191,31 +176,29 @@ class ClientUser extends User {
|
|
|
191
176
|
|
|
192
177
|
/**
|
|
193
178
|
* Sets the activity the client user is playing.
|
|
194
|
-
*
|
|
195
179
|
* @param {string|ActivityOptions} name Activity being played, or options for setting the activity
|
|
196
180
|
* @param {ActivityOptions} [options] Options for setting the activity
|
|
197
|
-
* @returns {
|
|
181
|
+
* @returns {ClientPresence}
|
|
198
182
|
* @example
|
|
199
183
|
* // Set the client user's activity
|
|
200
184
|
* client.user.setActivity('discord.js', { type: ActivityType.Watching });
|
|
201
185
|
*/
|
|
202
|
-
|
|
186
|
+
setActivity(name, options = {}) {
|
|
203
187
|
if (!name) return this.setPresence({ activities: [], shardId: options.shardId });
|
|
204
188
|
|
|
205
|
-
const activity = {
|
|
189
|
+
const activity = Object.assign({}, options, typeof name === 'object' ? name : { name });
|
|
206
190
|
return this.setPresence({ activities: [activity], shardId: activity.shardId });
|
|
207
191
|
}
|
|
208
192
|
|
|
209
193
|
/**
|
|
210
194
|
* Sets/removes the AFK flag for the client user.
|
|
211
|
-
*
|
|
212
195
|
* @param {boolean} [afk=true] Whether or not the user is AFK
|
|
213
196
|
* @param {number|number[]} [shardId] Shard Id(s) to have the AFK flag set on
|
|
214
|
-
* @returns {
|
|
197
|
+
* @returns {ClientPresence}
|
|
215
198
|
*/
|
|
216
|
-
|
|
199
|
+
setAFK(afk = true, shardId) {
|
|
217
200
|
return this.setPresence({ afk, shardId });
|
|
218
201
|
}
|
|
219
202
|
}
|
|
220
203
|
|
|
221
|
-
exports
|
|
204
|
+
module.exports = ClientUser;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
const Attachment = require('./Attachment');
|
|
4
|
+
const BaseInteraction = require('./BaseInteraction');
|
|
5
|
+
const InteractionWebhook = require('./InteractionWebhook');
|
|
6
|
+
const InteractionResponses = require('./interfaces/InteractionResponses');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Represents a command interaction.
|
|
10
|
-
*
|
|
11
10
|
* @extends {BaseInteraction}
|
|
12
11
|
* @implements {InteractionResponses}
|
|
13
12
|
* @abstract
|
|
@@ -18,63 +17,54 @@ class CommandInteraction extends BaseInteraction {
|
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* The id of the channel this interaction was sent in
|
|
21
|
-
*
|
|
22
20
|
* @type {Snowflake}
|
|
23
21
|
* @name CommandInteraction#channelId
|
|
24
22
|
*/
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* The invoked application command's id
|
|
28
|
-
*
|
|
29
26
|
* @type {Snowflake}
|
|
30
27
|
*/
|
|
31
28
|
this.commandId = data.data.id;
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* The invoked application command's name
|
|
35
|
-
*
|
|
36
32
|
* @type {string}
|
|
37
33
|
*/
|
|
38
34
|
this.commandName = data.data.name;
|
|
39
35
|
|
|
40
36
|
/**
|
|
41
37
|
* The invoked application command's type
|
|
42
|
-
*
|
|
43
38
|
* @type {ApplicationCommandType}
|
|
44
39
|
*/
|
|
45
40
|
this.commandType = data.data.type;
|
|
46
41
|
|
|
47
42
|
/**
|
|
48
43
|
* The id of the guild the invoked application command is registered to
|
|
49
|
-
*
|
|
50
44
|
* @type {?Snowflake}
|
|
51
45
|
*/
|
|
52
46
|
this.commandGuildId = data.data.guild_id ?? null;
|
|
53
47
|
|
|
54
48
|
/**
|
|
55
49
|
* Whether the reply to this interaction has been deferred
|
|
56
|
-
*
|
|
57
50
|
* @type {boolean}
|
|
58
51
|
*/
|
|
59
52
|
this.deferred = false;
|
|
60
53
|
|
|
61
54
|
/**
|
|
62
55
|
* Whether this interaction has already been replied to
|
|
63
|
-
*
|
|
64
56
|
* @type {boolean}
|
|
65
57
|
*/
|
|
66
58
|
this.replied = false;
|
|
67
59
|
|
|
68
60
|
/**
|
|
69
61
|
* Whether the reply to this interaction is ephemeral
|
|
70
|
-
*
|
|
71
62
|
* @type {?boolean}
|
|
72
63
|
*/
|
|
73
64
|
this.ephemeral = null;
|
|
74
65
|
|
|
75
66
|
/**
|
|
76
67
|
* An associated interaction webhook, can be used to further interact with this interaction
|
|
77
|
-
*
|
|
78
68
|
* @type {InteractionWebhook}
|
|
79
69
|
*/
|
|
80
70
|
this.webhook = new InteractionWebhook(this.client, this.applicationId, this.token);
|
|
@@ -82,7 +72,6 @@ class CommandInteraction extends BaseInteraction {
|
|
|
82
72
|
|
|
83
73
|
/**
|
|
84
74
|
* The invoked application command, if it was fetched before
|
|
85
|
-
*
|
|
86
75
|
* @type {?ApplicationCommand}
|
|
87
76
|
*/
|
|
88
77
|
get command() {
|
|
@@ -108,7 +97,6 @@ class CommandInteraction extends BaseInteraction {
|
|
|
108
97
|
|
|
109
98
|
/**
|
|
110
99
|
* Represents an option of a received command interaction.
|
|
111
|
-
*
|
|
112
100
|
* @typedef {Object} CommandInteractionOption
|
|
113
101
|
* @property {string} name The name of the option
|
|
114
102
|
* @property {ApplicationCommandOptionType} type The type of the option
|
|
@@ -127,7 +115,6 @@ class CommandInteraction extends BaseInteraction {
|
|
|
127
115
|
|
|
128
116
|
/**
|
|
129
117
|
* Transforms an option received from the API.
|
|
130
|
-
*
|
|
131
118
|
* @param {APIApplicationCommandOption} option The received option
|
|
132
119
|
* @param {APIInteractionDataResolved} resolved The resolved interaction data
|
|
133
120
|
* @returns {CommandInteractionOption}
|
|
@@ -163,26 +150,19 @@ class CommandInteraction extends BaseInteraction {
|
|
|
163
150
|
}
|
|
164
151
|
|
|
165
152
|
// These are here only for documentation purposes - they are implemented by InteractionResponses
|
|
166
|
-
|
|
153
|
+
/* eslint-disable no-empty-function */
|
|
167
154
|
deferReply() {}
|
|
168
|
-
|
|
169
155
|
reply() {}
|
|
170
|
-
|
|
171
156
|
fetchReply() {}
|
|
172
|
-
|
|
173
157
|
editReply() {}
|
|
174
|
-
|
|
175
158
|
deleteReply() {}
|
|
176
|
-
|
|
177
159
|
followUp() {}
|
|
178
|
-
|
|
179
160
|
launchActivity() {}
|
|
180
|
-
|
|
181
161
|
showModal() {}
|
|
182
|
-
|
|
162
|
+
sendPremiumRequired() {}
|
|
183
163
|
awaitModalSubmit() {}
|
|
184
164
|
}
|
|
185
165
|
|
|
186
166
|
InteractionResponses.applyToClass(CommandInteraction, ['deferUpdate', 'update']);
|
|
187
167
|
|
|
188
|
-
exports
|
|
168
|
+
module.exports = CommandInteraction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { ApplicationCommandOptionType } = require('discord-api-types/v10');
|
|
4
|
-
const { DiscordjsTypeError, ErrorCodes } = require('../errors
|
|
4
|
+
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A resolver for command interaction options.
|
|
@@ -10,7 +10,6 @@ class CommandInteractionOptionResolver {
|
|
|
10
10
|
constructor(client, options, resolved) {
|
|
11
11
|
/**
|
|
12
12
|
* The client that instantiated this.
|
|
13
|
-
*
|
|
14
13
|
* @name CommandInteractionOptionResolver#client
|
|
15
14
|
* @type {Client}
|
|
16
15
|
* @readonly
|
|
@@ -19,7 +18,6 @@ class CommandInteractionOptionResolver {
|
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* The name of the subcommand group.
|
|
22
|
-
*
|
|
23
21
|
* @type {?string}
|
|
24
22
|
* @private
|
|
25
23
|
*/
|
|
@@ -27,7 +25,6 @@ class CommandInteractionOptionResolver {
|
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* The name of the subcommand.
|
|
30
|
-
*
|
|
31
28
|
* @type {?string}
|
|
32
29
|
* @private
|
|
33
30
|
*/
|
|
@@ -36,7 +33,6 @@ class CommandInteractionOptionResolver {
|
|
|
36
33
|
/**
|
|
37
34
|
* The bottom-level options for the interaction.
|
|
38
35
|
* If there is a subcommand (or subcommand and group), this is the options for the subcommand.
|
|
39
|
-
*
|
|
40
36
|
* @type {CommandInteractionOption[]}
|
|
41
37
|
* @private
|
|
42
38
|
*/
|
|
@@ -47,7 +43,6 @@ class CommandInteractionOptionResolver {
|
|
|
47
43
|
this._group = this._hoistedOptions[0].name;
|
|
48
44
|
this._hoistedOptions = this._hoistedOptions[0].options ?? [];
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
// Hoist subcommand if present
|
|
52
47
|
if (this._hoistedOptions[0]?.type === ApplicationCommandOptionType.Subcommand) {
|
|
53
48
|
this._subcommand = this._hoistedOptions[0].name;
|
|
@@ -56,7 +51,6 @@ class CommandInteractionOptionResolver {
|
|
|
56
51
|
|
|
57
52
|
/**
|
|
58
53
|
* The interaction options array.
|
|
59
|
-
*
|
|
60
54
|
* @name CommandInteractionOptionResolver#data
|
|
61
55
|
* @type {ReadonlyArray<CommandInteractionOption>}
|
|
62
56
|
* @readonly
|
|
@@ -65,7 +59,6 @@ class CommandInteractionOptionResolver {
|
|
|
65
59
|
|
|
66
60
|
/**
|
|
67
61
|
* The interaction resolved data
|
|
68
|
-
*
|
|
69
62
|
* @name CommandInteractionOptionResolver#resolved
|
|
70
63
|
* @type {?Readonly<CommandInteractionResolvedData>}
|
|
71
64
|
*/
|
|
@@ -74,7 +67,6 @@ class CommandInteractionOptionResolver {
|
|
|
74
67
|
|
|
75
68
|
/**
|
|
76
69
|
* Gets an option by its name.
|
|
77
|
-
*
|
|
78
70
|
* @param {string} name The name of the option.
|
|
79
71
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
80
72
|
* @returns {?CommandInteractionOption} The option, if found.
|
|
@@ -85,19 +77,16 @@ class CommandInteractionOptionResolver {
|
|
|
85
77
|
if (required) {
|
|
86
78
|
throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionNotFound, name);
|
|
87
79
|
}
|
|
88
|
-
|
|
89
80
|
return null;
|
|
90
81
|
}
|
|
91
|
-
|
|
92
82
|
return option;
|
|
93
83
|
}
|
|
94
84
|
|
|
95
85
|
/**
|
|
96
86
|
* Gets an option by name and property and checks its type.
|
|
97
|
-
*
|
|
98
87
|
* @param {string} name The name of the option.
|
|
99
88
|
* @param {ApplicationCommandOptionType[]} allowedTypes The allowed types of the option.
|
|
100
|
-
* @param {string[]} properties The properties to check for `required`.
|
|
89
|
+
* @param {string[]} properties The properties to check for for `required`.
|
|
101
90
|
* @param {boolean} required Whether to throw an error if the option is not found.
|
|
102
91
|
* @returns {?CommandInteractionOption} The option, if found.
|
|
103
92
|
* @private
|
|
@@ -111,13 +100,11 @@ class CommandInteractionOptionResolver {
|
|
|
111
100
|
} else if (required && properties.every(prop => option[prop] === null || option[prop] === undefined)) {
|
|
112
101
|
throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionEmpty, name, option.type);
|
|
113
102
|
}
|
|
114
|
-
|
|
115
103
|
return option;
|
|
116
104
|
}
|
|
117
105
|
|
|
118
106
|
/**
|
|
119
107
|
* Gets the selected subcommand.
|
|
120
|
-
*
|
|
121
108
|
* @param {boolean} [required=true] Whether to throw an error if there is no subcommand.
|
|
122
109
|
* @returns {?string} The name of the selected subcommand, or null if not set and not required.
|
|
123
110
|
*/
|
|
@@ -125,13 +112,11 @@ class CommandInteractionOptionResolver {
|
|
|
125
112
|
if (required && !this._subcommand) {
|
|
126
113
|
throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionNoSubcommand);
|
|
127
114
|
}
|
|
128
|
-
|
|
129
115
|
return this._subcommand;
|
|
130
116
|
}
|
|
131
117
|
|
|
132
118
|
/**
|
|
133
119
|
* Gets the selected subcommand group.
|
|
134
|
-
*
|
|
135
120
|
* @param {boolean} [required=false] Whether to throw an error if there is no subcommand group.
|
|
136
121
|
* @returns {?string} The name of the selected subcommand group, or null if not set and not required.
|
|
137
122
|
*/
|
|
@@ -139,13 +124,11 @@ class CommandInteractionOptionResolver {
|
|
|
139
124
|
if (required && !this._group) {
|
|
140
125
|
throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionNoSubcommandGroup);
|
|
141
126
|
}
|
|
142
|
-
|
|
143
127
|
return this._group;
|
|
144
128
|
}
|
|
145
129
|
|
|
146
130
|
/**
|
|
147
131
|
* Gets a boolean option.
|
|
148
|
-
*
|
|
149
132
|
* @param {string} name The name of the option.
|
|
150
133
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
151
134
|
* @returns {?boolean} The value of the option, or null if not set and not required.
|
|
@@ -157,7 +140,6 @@ class CommandInteractionOptionResolver {
|
|
|
157
140
|
|
|
158
141
|
/**
|
|
159
142
|
* Gets a channel option.
|
|
160
|
-
*
|
|
161
143
|
* @param {string} name The name of the option.
|
|
162
144
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
163
145
|
* @param {ChannelType[]} [channelTypes=[]] The allowed types of channels. If empty, all channel types are allowed.
|
|
@@ -182,7 +164,6 @@ class CommandInteractionOptionResolver {
|
|
|
182
164
|
|
|
183
165
|
/**
|
|
184
166
|
* Gets a string option.
|
|
185
|
-
*
|
|
186
167
|
* @param {string} name The name of the option.
|
|
187
168
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
188
169
|
* @returns {?string} The value of the option, or null if not set and not required.
|
|
@@ -194,7 +175,6 @@ class CommandInteractionOptionResolver {
|
|
|
194
175
|
|
|
195
176
|
/**
|
|
196
177
|
* Gets an integer option.
|
|
197
|
-
*
|
|
198
178
|
* @param {string} name The name of the option.
|
|
199
179
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
200
180
|
* @returns {?number} The value of the option, or null if not set and not required.
|
|
@@ -206,7 +186,6 @@ class CommandInteractionOptionResolver {
|
|
|
206
186
|
|
|
207
187
|
/**
|
|
208
188
|
* Gets a number option.
|
|
209
|
-
*
|
|
210
189
|
* @param {string} name The name of the option.
|
|
211
190
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
212
191
|
* @returns {?number} The value of the option, or null if not set and not required.
|
|
@@ -218,7 +197,6 @@ class CommandInteractionOptionResolver {
|
|
|
218
197
|
|
|
219
198
|
/**
|
|
220
199
|
* Gets a user option.
|
|
221
|
-
*
|
|
222
200
|
* @param {string} name The name of the option.
|
|
223
201
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
224
202
|
* @returns {?User} The value of the option, or null if not set and not required.
|
|
@@ -235,7 +213,6 @@ class CommandInteractionOptionResolver {
|
|
|
235
213
|
|
|
236
214
|
/**
|
|
237
215
|
* Gets a member option.
|
|
238
|
-
*
|
|
239
216
|
* @param {string} name The name of the option.
|
|
240
217
|
* @returns {?(GuildMember|APIGuildMember)}
|
|
241
218
|
* The value of the option, or null if the user is not present in the guild or the option is not set.
|
|
@@ -252,7 +229,6 @@ class CommandInteractionOptionResolver {
|
|
|
252
229
|
|
|
253
230
|
/**
|
|
254
231
|
* Gets a role option.
|
|
255
|
-
*
|
|
256
232
|
* @param {string} name The name of the option.
|
|
257
233
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
258
234
|
* @returns {?(Role|APIRole)} The value of the option, or null if not set and not required.
|
|
@@ -269,7 +245,6 @@ class CommandInteractionOptionResolver {
|
|
|
269
245
|
|
|
270
246
|
/**
|
|
271
247
|
* Gets an attachment option.
|
|
272
|
-
*
|
|
273
248
|
* @param {string} name The name of the option.
|
|
274
249
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
275
250
|
* @returns {?Attachment} The value of the option, or null if not set and not required.
|
|
@@ -281,7 +256,6 @@ class CommandInteractionOptionResolver {
|
|
|
281
256
|
|
|
282
257
|
/**
|
|
283
258
|
* Gets a mentionable option.
|
|
284
|
-
*
|
|
285
259
|
* @param {string} name The name of the option.
|
|
286
260
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
287
261
|
* @returns {?(User|GuildMember|APIGuildMember|Role|APIRole)}
|
|
@@ -299,7 +273,6 @@ class CommandInteractionOptionResolver {
|
|
|
299
273
|
|
|
300
274
|
/**
|
|
301
275
|
* Gets a message option.
|
|
302
|
-
*
|
|
303
276
|
* @param {string} name The name of the option.
|
|
304
277
|
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
|
305
278
|
* @returns {?Message}
|
|
@@ -312,7 +285,6 @@ class CommandInteractionOptionResolver {
|
|
|
312
285
|
|
|
313
286
|
/**
|
|
314
287
|
* The full autocomplete option object.
|
|
315
|
-
*
|
|
316
288
|
* @typedef {Object} AutocompleteFocusedOption
|
|
317
289
|
* @property {string} name The name of the option
|
|
318
290
|
* @property {ApplicationCommandOptionType} type The type of the application command option
|
|
@@ -322,15 +294,15 @@ class CommandInteractionOptionResolver {
|
|
|
322
294
|
|
|
323
295
|
/**
|
|
324
296
|
* Gets the focused option.
|
|
325
|
-
*
|
|
326
|
-
* @returns {AutocompleteFocusedOption}
|
|
327
|
-
* The
|
|
297
|
+
* @param {boolean} [getFull=false] Whether to get the full option object
|
|
298
|
+
* @returns {string|AutocompleteFocusedOption}
|
|
299
|
+
* The value of the option, or the whole option if getFull is true
|
|
328
300
|
*/
|
|
329
|
-
getFocused() {
|
|
301
|
+
getFocused(getFull = false) {
|
|
330
302
|
const focusedOption = this._hoistedOptions.find(option => option.focused);
|
|
331
303
|
if (!focusedOption) throw new DiscordjsTypeError(ErrorCodes.AutocompleteInteractionOptionNoFocusedOption);
|
|
332
|
-
return focusedOption;
|
|
304
|
+
return getFull ? focusedOption : focusedOption.value;
|
|
333
305
|
}
|
|
334
306
|
}
|
|
335
307
|
|
|
336
|
-
exports
|
|
308
|
+
module.exports = CommandInteractionOptionResolver;
|
|
@@ -9,7 +9,6 @@ class Component {
|
|
|
9
9
|
constructor(data) {
|
|
10
10
|
/**
|
|
11
11
|
* The API data associated with this component
|
|
12
|
-
*
|
|
13
12
|
* @type {APIMessageComponent}
|
|
14
13
|
*/
|
|
15
14
|
this.data = data;
|
|
@@ -17,7 +16,6 @@ class Component {
|
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* The id of this component
|
|
20
|
-
*
|
|
21
19
|
* @type {number}
|
|
22
20
|
* @readonly
|
|
23
21
|
*/
|
|
@@ -27,7 +25,6 @@ class Component {
|
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* The type of the component
|
|
30
|
-
*
|
|
31
28
|
* @type {ComponentType}
|
|
32
29
|
* @readonly
|
|
33
30
|
*/
|
|
@@ -37,7 +34,6 @@ class Component {
|
|
|
37
34
|
|
|
38
35
|
/**
|
|
39
36
|
* Whether or not the given components are equal
|
|
40
|
-
*
|
|
41
37
|
* @param {Component|APIMessageComponent} other The component to compare against
|
|
42
38
|
* @returns {boolean}
|
|
43
39
|
*/
|
|
@@ -45,13 +41,11 @@ class Component {
|
|
|
45
41
|
if (other instanceof Component) {
|
|
46
42
|
return isEqual(other.data, this.data);
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
return isEqual(other, this.data);
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
/**
|
|
53
48
|
* Returns the API-compatible JSON for this component
|
|
54
|
-
*
|
|
55
49
|
* @returns {APIMessageComponent}
|
|
56
50
|
*/
|
|
57
51
|
toJSON() {
|
|
@@ -59,4 +53,4 @@ class Component {
|
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
55
|
|
|
62
|
-
exports
|
|
56
|
+
module.exports = Component;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const {
|
|
3
|
+
const Component = require('./Component');
|
|
4
|
+
const { createComponent } = require('../util/Components');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Represents a container component
|
|
8
|
-
*
|
|
9
8
|
* @extends {Component}
|
|
10
9
|
*/
|
|
11
10
|
class ContainerComponent extends Component {
|
|
@@ -14,7 +13,6 @@ class ContainerComponent extends Component {
|
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* The components in this container
|
|
17
|
-
*
|
|
18
16
|
* @type {Component[]}
|
|
19
17
|
* @readonly
|
|
20
18
|
*/
|
|
@@ -23,7 +21,6 @@ class ContainerComponent extends Component {
|
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* The accent color of this container
|
|
26
|
-
*
|
|
27
24
|
* @type {?number}
|
|
28
25
|
* @readonly
|
|
29
26
|
*/
|
|
@@ -33,7 +30,6 @@ class ContainerComponent extends Component {
|
|
|
33
30
|
|
|
34
31
|
/**
|
|
35
32
|
* The hex accent color of this container
|
|
36
|
-
*
|
|
37
33
|
* @type {?string}
|
|
38
34
|
* @readonly
|
|
39
35
|
*/
|
|
@@ -45,7 +41,6 @@ class ContainerComponent extends Component {
|
|
|
45
41
|
|
|
46
42
|
/**
|
|
47
43
|
* Whether this container is spoilered
|
|
48
|
-
*
|
|
49
44
|
* @type {boolean}
|
|
50
45
|
* @readonly
|
|
51
46
|
*/
|
|
@@ -55,7 +50,6 @@ class ContainerComponent extends Component {
|
|
|
55
50
|
|
|
56
51
|
/**
|
|
57
52
|
* Returns the API-compatible JSON for this component
|
|
58
|
-
*
|
|
59
53
|
* @returns {APIContainerComponent}
|
|
60
54
|
*/
|
|
61
55
|
toJSON() {
|
|
@@ -63,4 +57,4 @@ class ContainerComponent extends Component {
|
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
|
|
66
|
-
exports
|
|
60
|
+
module.exports = ContainerComponent;
|