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
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
const { DiscordSnowflake } = require('../util/LolkaSnowflake');
|
|
4
4
|
const { ApplicationCommandOptionType } = require('discord-api-types/v10');
|
|
5
5
|
const isEqual = require('fast-deep-equal');
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const Base = require('./Base');
|
|
7
|
+
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
|
8
|
+
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Represents an application command.
|
|
12
|
-
*
|
|
13
12
|
* @extends {Base}
|
|
14
13
|
*/
|
|
15
14
|
class ApplicationCommand extends Base {
|
|
@@ -18,21 +17,18 @@ class ApplicationCommand extends Base {
|
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* The command's id
|
|
21
|
-
*
|
|
22
20
|
* @type {Snowflake}
|
|
23
21
|
*/
|
|
24
22
|
this.id = data.id;
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* The parent application's id
|
|
28
|
-
*
|
|
29
26
|
* @type {Snowflake}
|
|
30
27
|
*/
|
|
31
28
|
this.applicationId = data.application_id;
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* The guild this command is part of
|
|
35
|
-
*
|
|
36
32
|
* @type {?Guild}
|
|
37
33
|
*/
|
|
38
34
|
this.guild = guild ?? null;
|
|
@@ -40,28 +36,24 @@ class ApplicationCommand extends Base {
|
|
|
40
36
|
/**
|
|
41
37
|
* The guild's id this command is part of, this may be non-null when `guild` is `null` if the command
|
|
42
38
|
* was fetched from the `ApplicationCommandManager`
|
|
43
|
-
*
|
|
44
39
|
* @type {?Snowflake}
|
|
45
40
|
*/
|
|
46
41
|
this.guildId = guild?.id ?? guildId ?? null;
|
|
47
42
|
|
|
48
43
|
/**
|
|
49
44
|
* The manager for permissions of this command on its guild or arbitrary guilds when the command is global
|
|
50
|
-
*
|
|
51
45
|
* @type {ApplicationCommandPermissionsManager}
|
|
52
46
|
*/
|
|
53
47
|
this.permissions = new ApplicationCommandPermissionsManager(this);
|
|
54
48
|
|
|
55
49
|
/**
|
|
56
50
|
* The type of this application command
|
|
57
|
-
*
|
|
58
51
|
* @type {ApplicationCommandType}
|
|
59
52
|
*/
|
|
60
53
|
this.type = data.type;
|
|
61
54
|
|
|
62
55
|
/**
|
|
63
56
|
* Whether this command is age-restricted (18+)
|
|
64
|
-
*
|
|
65
57
|
* @type {boolean}
|
|
66
58
|
*/
|
|
67
59
|
this.nsfw = data.nsfw ?? false;
|
|
@@ -73,7 +65,6 @@ class ApplicationCommand extends Base {
|
|
|
73
65
|
if ('name' in data) {
|
|
74
66
|
/**
|
|
75
67
|
* The name of this command
|
|
76
|
-
*
|
|
77
68
|
* @type {string}
|
|
78
69
|
*/
|
|
79
70
|
this.name = data.name;
|
|
@@ -82,7 +73,6 @@ class ApplicationCommand extends Base {
|
|
|
82
73
|
if ('name_localizations' in data) {
|
|
83
74
|
/**
|
|
84
75
|
* The name localizations for this command
|
|
85
|
-
*
|
|
86
76
|
* @type {?LocalizationMap}
|
|
87
77
|
*/
|
|
88
78
|
this.nameLocalizations = data.name_localizations;
|
|
@@ -93,7 +83,6 @@ class ApplicationCommand extends Base {
|
|
|
93
83
|
if ('name_localized' in data) {
|
|
94
84
|
/**
|
|
95
85
|
* The localized name for this command
|
|
96
|
-
*
|
|
97
86
|
* @type {?string}
|
|
98
87
|
*/
|
|
99
88
|
this.nameLocalized = data.name_localized;
|
|
@@ -104,7 +93,6 @@ class ApplicationCommand extends Base {
|
|
|
104
93
|
if ('description' in data) {
|
|
105
94
|
/**
|
|
106
95
|
* The description of this command
|
|
107
|
-
*
|
|
108
96
|
* @type {string}
|
|
109
97
|
*/
|
|
110
98
|
this.description = data.description;
|
|
@@ -113,7 +101,6 @@ class ApplicationCommand extends Base {
|
|
|
113
101
|
if ('description_localizations' in data) {
|
|
114
102
|
/**
|
|
115
103
|
* The description localizations for this command
|
|
116
|
-
*
|
|
117
104
|
* @type {?LocalizationMap}
|
|
118
105
|
*/
|
|
119
106
|
this.descriptionLocalizations = data.description_localizations;
|
|
@@ -124,7 +111,6 @@ class ApplicationCommand extends Base {
|
|
|
124
111
|
if ('description_localized' in data) {
|
|
125
112
|
/**
|
|
126
113
|
* The localized description for this command
|
|
127
|
-
*
|
|
128
114
|
* @type {?string}
|
|
129
115
|
*/
|
|
130
116
|
this.descriptionLocalized = data.description_localized;
|
|
@@ -135,18 +121,16 @@ class ApplicationCommand extends Base {
|
|
|
135
121
|
if ('options' in data) {
|
|
136
122
|
/**
|
|
137
123
|
* The options of this command
|
|
138
|
-
*
|
|
139
|
-
* @type {?ApplicationCommandOption[]}
|
|
124
|
+
* @type {ApplicationCommandOption[]}
|
|
140
125
|
*/
|
|
141
126
|
this.options = data.options.map(option => this.constructor.transformOption(option, true));
|
|
142
127
|
} else {
|
|
143
|
-
this.options ??=
|
|
128
|
+
this.options ??= [];
|
|
144
129
|
}
|
|
145
130
|
|
|
146
131
|
if ('default_member_permissions' in data) {
|
|
147
132
|
/**
|
|
148
133
|
* The default bitfield used to determine whether this command be used in a guild
|
|
149
|
-
*
|
|
150
134
|
* @type {?Readonly<PermissionsBitField>}
|
|
151
135
|
*/
|
|
152
136
|
this.defaultMemberPermissions = data.default_member_permissions
|
|
@@ -156,11 +140,22 @@ class ApplicationCommand extends Base {
|
|
|
156
140
|
this.defaultMemberPermissions ??= null;
|
|
157
141
|
}
|
|
158
142
|
|
|
143
|
+
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}
|
|
148
|
+
* @deprecated Use {@link ApplicationCommand#contexts} instead.
|
|
149
|
+
*/
|
|
150
|
+
this.dmPermission = data.dm_permission;
|
|
151
|
+
} else {
|
|
152
|
+
this.dmPermission ??= null;
|
|
153
|
+
}
|
|
154
|
+
|
|
159
155
|
if ('integration_types' in data) {
|
|
160
156
|
/**
|
|
161
157
|
* Installation context(s) where the command is available
|
|
162
158
|
* <info>Only for globally-scoped commands</info>
|
|
163
|
-
*
|
|
164
159
|
* @type {?ApplicationIntegrationType[]}
|
|
165
160
|
*/
|
|
166
161
|
this.integrationTypes = data.integration_types;
|
|
@@ -172,7 +167,6 @@ class ApplicationCommand extends Base {
|
|
|
172
167
|
/**
|
|
173
168
|
* Interaction context(s) where the command can be used
|
|
174
169
|
* <info>Only for globally-scoped commands</info>
|
|
175
|
-
*
|
|
176
170
|
* @type {?InteractionContextType[]}
|
|
177
171
|
*/
|
|
178
172
|
this.contexts = data.contexts;
|
|
@@ -185,7 +179,6 @@ class ApplicationCommand extends Base {
|
|
|
185
179
|
* Determines whether the interaction is handled by the app's interactions handler or by Discord.
|
|
186
180
|
* <info>Only available for {@link ApplicationCommandType.PrimaryEntryPoint} commands on
|
|
187
181
|
* applications with the {@link ApplicationFlags.Embedded} flag (i.e, those that have an Activity)</info>
|
|
188
|
-
*
|
|
189
182
|
* @type {?EntryPointCommandHandlerType}
|
|
190
183
|
*/
|
|
191
184
|
this.handler = data.handler;
|
|
@@ -196,7 +189,6 @@ class ApplicationCommand extends Base {
|
|
|
196
189
|
if ('version' in data) {
|
|
197
190
|
/**
|
|
198
191
|
* Autoincrementing version identifier updated during substantial record changes
|
|
199
|
-
*
|
|
200
192
|
* @type {Snowflake}
|
|
201
193
|
*/
|
|
202
194
|
this.version = data.version;
|
|
@@ -205,7 +197,6 @@ class ApplicationCommand extends Base {
|
|
|
205
197
|
|
|
206
198
|
/**
|
|
207
199
|
* The timestamp the command was created at
|
|
208
|
-
*
|
|
209
200
|
* @type {number}
|
|
210
201
|
* @readonly
|
|
211
202
|
*/
|
|
@@ -215,7 +206,6 @@ class ApplicationCommand extends Base {
|
|
|
215
206
|
|
|
216
207
|
/**
|
|
217
208
|
* The time the command was created at
|
|
218
|
-
*
|
|
219
209
|
* @type {Date}
|
|
220
210
|
* @readonly
|
|
221
211
|
*/
|
|
@@ -225,7 +215,6 @@ class ApplicationCommand extends Base {
|
|
|
225
215
|
|
|
226
216
|
/**
|
|
227
217
|
* The manager that this command belongs to
|
|
228
|
-
*
|
|
229
218
|
* @type {ApplicationCommandManager}
|
|
230
219
|
* @readonly
|
|
231
220
|
*/
|
|
@@ -235,7 +224,6 @@ class ApplicationCommand extends Base {
|
|
|
235
224
|
|
|
236
225
|
/**
|
|
237
226
|
* Data for creating or editing an application command.
|
|
238
|
-
*
|
|
239
227
|
* @typedef {Object} ApplicationCommandData
|
|
240
228
|
* @property {string} name The name of the command, must be in all lowercase if type is
|
|
241
229
|
* {@link ApplicationCommandType.ChatInput}
|
|
@@ -249,6 +237,7 @@ class ApplicationCommand extends Base {
|
|
|
249
237
|
* @property {ApplicationCommandOptionData[]} [options] Options for the command
|
|
250
238
|
* @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
|
|
251
239
|
* a member needs in order to run the command
|
|
240
|
+
* @property {boolean} [dmPermission] Whether the command is enabled in DMs
|
|
252
241
|
* @property {ApplicationIntegrationType[]} [integrationTypes] Installation contexts where the command is available
|
|
253
242
|
* @property {InteractionContextType[]} [contexts] Interaction contexts where the command can be used
|
|
254
243
|
* @property {EntryPointCommandHandlerType} [handler] Whether the interaction is handled by the app's
|
|
@@ -261,7 +250,6 @@ class ApplicationCommand extends Base {
|
|
|
261
250
|
* API style `snake_case` properties can be used for compatibility with generators like `@discordjs/builders`.</info>
|
|
262
251
|
* <warn>Note that providing a value for the `camelCase` counterpart for any `snake_case` property
|
|
263
252
|
* will discard the provided `snake_case` property.</warn>
|
|
264
|
-
*
|
|
265
253
|
* @typedef {Object} ApplicationCommandOptionData
|
|
266
254
|
* @property {ApplicationCommandOptionType} type The type of the option
|
|
267
255
|
* @property {string} name The name of the option
|
|
@@ -295,7 +283,6 @@ class ApplicationCommand extends Base {
|
|
|
295
283
|
|
|
296
284
|
/**
|
|
297
285
|
* Edits this application command.
|
|
298
|
-
*
|
|
299
286
|
* @param {Partial<ApplicationCommandData>} data The data to update the command with
|
|
300
287
|
* @returns {Promise<ApplicationCommand>}
|
|
301
288
|
* @example
|
|
@@ -306,23 +293,21 @@ class ApplicationCommand extends Base {
|
|
|
306
293
|
* .then(console.log)
|
|
307
294
|
* .catch(console.error);
|
|
308
295
|
*/
|
|
309
|
-
|
|
296
|
+
edit(data) {
|
|
310
297
|
return this.manager.edit(this, data, this.guildId);
|
|
311
298
|
}
|
|
312
299
|
|
|
313
300
|
/**
|
|
314
301
|
* Edits the name of this ApplicationCommand
|
|
315
|
-
*
|
|
316
302
|
* @param {string} name The new name of the command
|
|
317
303
|
* @returns {Promise<ApplicationCommand>}
|
|
318
304
|
*/
|
|
319
|
-
|
|
305
|
+
setName(name) {
|
|
320
306
|
return this.edit({ name });
|
|
321
307
|
}
|
|
322
308
|
|
|
323
309
|
/**
|
|
324
310
|
* Edits the localized names of this ApplicationCommand
|
|
325
|
-
*
|
|
326
311
|
* @param {LocalizationMap} nameLocalizations The new localized names for the command
|
|
327
312
|
* @returns {Promise<ApplicationCommand>}
|
|
328
313
|
* @example
|
|
@@ -334,23 +319,21 @@ class ApplicationCommand extends Base {
|
|
|
334
319
|
* .then(console.log)
|
|
335
320
|
* .catch(console.error)
|
|
336
321
|
*/
|
|
337
|
-
|
|
322
|
+
setNameLocalizations(nameLocalizations) {
|
|
338
323
|
return this.edit({ nameLocalizations });
|
|
339
324
|
}
|
|
340
325
|
|
|
341
326
|
/**
|
|
342
327
|
* Edits the description of this ApplicationCommand
|
|
343
|
-
*
|
|
344
328
|
* @param {string} description The new description of the command
|
|
345
329
|
* @returns {Promise<ApplicationCommand>}
|
|
346
330
|
*/
|
|
347
|
-
|
|
331
|
+
setDescription(description) {
|
|
348
332
|
return this.edit({ description });
|
|
349
333
|
}
|
|
350
334
|
|
|
351
335
|
/**
|
|
352
336
|
* Edits the localized descriptions of this ApplicationCommand
|
|
353
|
-
*
|
|
354
337
|
* @param {LocalizationMap} descriptionLocalizations The new localized descriptions for the command
|
|
355
338
|
* @returns {Promise<ApplicationCommand>}
|
|
356
339
|
* @example
|
|
@@ -362,33 +345,39 @@ class ApplicationCommand extends Base {
|
|
|
362
345
|
* .then(console.log)
|
|
363
346
|
* .catch(console.error)
|
|
364
347
|
*/
|
|
365
|
-
|
|
348
|
+
setDescriptionLocalizations(descriptionLocalizations) {
|
|
366
349
|
return this.edit({ descriptionLocalizations });
|
|
367
350
|
}
|
|
368
351
|
|
|
369
352
|
/**
|
|
370
353
|
* Edits the default member permissions of this ApplicationCommand
|
|
371
|
-
*
|
|
372
354
|
* @param {?PermissionResolvable} defaultMemberPermissions The default member permissions required to run this command
|
|
373
355
|
* @returns {Promise<ApplicationCommand>}
|
|
374
356
|
*/
|
|
375
|
-
|
|
357
|
+
setDefaultMemberPermissions(defaultMemberPermissions) {
|
|
376
358
|
return this.edit({ defaultMemberPermissions });
|
|
377
359
|
}
|
|
378
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Edits the DM permission of this ApplicationCommand
|
|
363
|
+
* @param {boolean} [dmPermission=true] Whether the command can be used in DMs
|
|
364
|
+
* @returns {Promise<ApplicationCommand>}
|
|
365
|
+
*/
|
|
366
|
+
setDMPermission(dmPermission = true) {
|
|
367
|
+
return this.edit({ dmPermission });
|
|
368
|
+
}
|
|
369
|
+
|
|
379
370
|
/**
|
|
380
371
|
* Edits the options of this ApplicationCommand
|
|
381
|
-
*
|
|
382
372
|
* @param {ApplicationCommandOptionData[]} options The options to set for this command
|
|
383
373
|
* @returns {Promise<ApplicationCommand>}
|
|
384
374
|
*/
|
|
385
|
-
|
|
375
|
+
setOptions(options) {
|
|
386
376
|
return this.edit({ options });
|
|
387
377
|
}
|
|
388
378
|
|
|
389
379
|
/**
|
|
390
380
|
* Deletes this command.
|
|
391
|
-
*
|
|
392
381
|
* @returns {Promise<ApplicationCommand>}
|
|
393
382
|
* @example
|
|
394
383
|
* // Delete this command
|
|
@@ -396,7 +385,7 @@ class ApplicationCommand extends Base {
|
|
|
396
385
|
* .then(console.log)
|
|
397
386
|
* .catch(console.error);
|
|
398
387
|
*/
|
|
399
|
-
|
|
388
|
+
delete() {
|
|
400
389
|
return this.manager.delete(this, this.guildId);
|
|
401
390
|
}
|
|
402
391
|
|
|
@@ -404,7 +393,6 @@ class ApplicationCommand extends Base {
|
|
|
404
393
|
* Whether this command equals another command. It compares all properties, so for most operations
|
|
405
394
|
* it is advisable to just compare `command.id === command2.id` as it is much faster and is often
|
|
406
395
|
* what most users need.
|
|
407
|
-
*
|
|
408
396
|
* @param {ApplicationCommand|ApplicationCommandData|APIApplicationCommand} command The command to compare with
|
|
409
397
|
* @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
|
|
410
398
|
* order in the array <info>The client may not always respect this ordering!</info>
|
|
@@ -415,6 +403,7 @@ class ApplicationCommand extends Base {
|
|
|
415
403
|
if (command.id && this.id !== command.id) return false;
|
|
416
404
|
|
|
417
405
|
let defaultMemberPermissions = null;
|
|
406
|
+
let dmPermission = command.dmPermission ?? command.dm_permission;
|
|
418
407
|
|
|
419
408
|
if ('default_member_permissions' in command) {
|
|
420
409
|
defaultMemberPermissions = command.default_member_permissions
|
|
@@ -424,9 +413,9 @@ class ApplicationCommand extends Base {
|
|
|
424
413
|
|
|
425
414
|
if ('defaultMemberPermissions' in command) {
|
|
426
415
|
defaultMemberPermissions =
|
|
427
|
-
command.defaultMemberPermissions
|
|
428
|
-
?
|
|
429
|
-
:
|
|
416
|
+
command.defaultMemberPermissions !== null
|
|
417
|
+
? new PermissionsBitField(command.defaultMemberPermissions).bitfield
|
|
418
|
+
: null;
|
|
430
419
|
}
|
|
431
420
|
|
|
432
421
|
// Check top level parameters
|
|
@@ -436,8 +425,11 @@ class ApplicationCommand extends Base {
|
|
|
436
425
|
('version' in command && command.version !== this.version) ||
|
|
437
426
|
(command.type && command.type !== this.type) ||
|
|
438
427
|
('nsfw' in command && command.nsfw !== this.nsfw) ||
|
|
439
|
-
|
|
428
|
+
// Future proof for options being nullable
|
|
429
|
+
// TODO: remove ?? 0 on each when nullable
|
|
430
|
+
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
|
|
440
431
|
defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
|
|
432
|
+
(dmPermission !== undefined && dmPermission !== this.dmPermission) ||
|
|
441
433
|
!isEqual(command.nameLocalizations ?? command.name_localizations ?? {}, this.nameLocalizations ?? {}) ||
|
|
442
434
|
!isEqual(
|
|
443
435
|
command.descriptionLocalizations ?? command.description_localizations ?? {},
|
|
@@ -450,18 +442,15 @@ class ApplicationCommand extends Base {
|
|
|
450
442
|
return false;
|
|
451
443
|
}
|
|
452
444
|
|
|
453
|
-
// Don't need to check both because we already checked the lengths above
|
|
454
445
|
if (command.options) {
|
|
455
446
|
return this.constructor.optionsEqual(this.options, command.options, enforceOptionOrder);
|
|
456
447
|
}
|
|
457
|
-
|
|
458
448
|
return true;
|
|
459
449
|
}
|
|
460
450
|
|
|
461
451
|
/**
|
|
462
452
|
* Recursively checks that all options for an {@link ApplicationCommand} are equal to the provided options.
|
|
463
453
|
* In most cases it is better to compare using {@link ApplicationCommand#equals}
|
|
464
|
-
*
|
|
465
454
|
* @param {ApplicationCommandOptionData[]} existing The options on the existing command,
|
|
466
455
|
* should be {@link ApplicationCommand#options}
|
|
467
456
|
* @param {ApplicationCommandOptionData[]|APIApplicationCommandOption[]} options The options to compare against
|
|
@@ -474,20 +463,17 @@ class ApplicationCommand extends Base {
|
|
|
474
463
|
if (enforceOptionOrder) {
|
|
475
464
|
return existing.every((option, index) => this._optionEquals(option, options[index], enforceOptionOrder));
|
|
476
465
|
}
|
|
477
|
-
|
|
478
466
|
const newOptions = new Map(options.map(option => [option.name, option]));
|
|
479
467
|
for (const option of existing) {
|
|
480
468
|
const foundOption = newOptions.get(option.name);
|
|
481
469
|
if (!foundOption || !this._optionEquals(option, foundOption)) return false;
|
|
482
470
|
}
|
|
483
|
-
|
|
484
471
|
return true;
|
|
485
472
|
}
|
|
486
473
|
|
|
487
474
|
/**
|
|
488
475
|
* Checks that an option for an {@link ApplicationCommand} is equal to the provided option
|
|
489
476
|
* In most cases it is better to compare using {@link ApplicationCommand#equals}
|
|
490
|
-
*
|
|
491
477
|
* @param {ApplicationCommandOptionData} existing The option on the existing command,
|
|
492
478
|
* should be from {@link ApplicationCommand#options}
|
|
493
479
|
* @param {ApplicationCommandOptionData|APIApplicationCommandOption} option The option to compare against
|
|
@@ -537,7 +523,6 @@ class ApplicationCommand extends Base {
|
|
|
537
523
|
) {
|
|
538
524
|
return false;
|
|
539
525
|
}
|
|
540
|
-
|
|
541
526
|
if (!enforceOptionOrder) {
|
|
542
527
|
const newChoices = new Map(option.choices.map(choice => [choice.name, choice]));
|
|
543
528
|
for (const choice of existing.choices) {
|
|
@@ -557,13 +542,11 @@ class ApplicationCommand extends Base {
|
|
|
557
542
|
if (existing.options) {
|
|
558
543
|
return this.optionsEqual(existing.options, option.options, enforceOptionOrder);
|
|
559
544
|
}
|
|
560
|
-
|
|
561
545
|
return true;
|
|
562
546
|
}
|
|
563
547
|
|
|
564
548
|
/**
|
|
565
549
|
* An option for an application command or subcommand.
|
|
566
|
-
*
|
|
567
550
|
* @typedef {Object} ApplicationCommandOption
|
|
568
551
|
* @property {ApplicationCommandOptionType} type The type of the option
|
|
569
552
|
* @property {string} name The name of the option
|
|
@@ -578,7 +561,7 @@ class ApplicationCommand extends Base {
|
|
|
578
561
|
* {@link ApplicationCommandOptionType.Number} option
|
|
579
562
|
* @property {ApplicationCommandOptionChoice[]} [choices] The choices of the option for the user to pick from
|
|
580
563
|
* @property {ApplicationCommandOption[]} [options] Additional options if this option is a subcommand (group)
|
|
581
|
-
* @property {
|
|
564
|
+
* @property {ApplicationCommandOptionAllowedChannelTypes[]} [channelTypes] When the option type is channel,
|
|
582
565
|
* the allowed types of channels that can be selected
|
|
583
566
|
* @property {number} [minValue] The minimum value for an {@link ApplicationCommandOptionType.Integer} or
|
|
584
567
|
* {@link ApplicationCommandOptionType.Number} option
|
|
@@ -592,17 +575,15 @@ class ApplicationCommand extends Base {
|
|
|
592
575
|
|
|
593
576
|
/**
|
|
594
577
|
* A choice for an application command option.
|
|
595
|
-
*
|
|
596
578
|
* @typedef {Object} ApplicationCommandOptionChoice
|
|
597
579
|
* @property {string} name The name of the choice
|
|
598
580
|
* @property {?string} nameLocalized The localized name of the choice in the provided locale, if any
|
|
599
|
-
* @property {?
|
|
581
|
+
* @property {?Object<string, string>} [nameLocalizations] The localized names for this choice
|
|
600
582
|
* @property {string|number} value The value of the choice
|
|
601
583
|
*/
|
|
602
584
|
|
|
603
585
|
/**
|
|
604
586
|
* Transforms an {@link ApplicationCommandOptionData} object into something that can be used with the API.
|
|
605
|
-
*
|
|
606
587
|
* @param {ApplicationCommandOptionData|ApplicationCommandOption} option The option to transform
|
|
607
588
|
* @param {boolean} [received] Whether this option has been received from Discord
|
|
608
589
|
* @returns {APIApplicationCommandOption}
|
|
@@ -649,9 +630,10 @@ class ApplicationCommand extends Base {
|
|
|
649
630
|
}
|
|
650
631
|
}
|
|
651
632
|
|
|
652
|
-
exports
|
|
633
|
+
module.exports = ApplicationCommand;
|
|
653
634
|
|
|
635
|
+
/* eslint-disable max-len */
|
|
654
636
|
/**
|
|
655
|
-
* @external
|
|
656
|
-
* @see {@link https://discord.js.org/docs/packages/builders/stable/
|
|
637
|
+
* @external ApplicationCommandOptionAllowedChannelTypes
|
|
638
|
+
* @see {@link https://discord.js.org/docs/packages/builders/stable/ApplicationCommandOptionAllowedChannelTypes:TypeAlias}
|
|
657
639
|
*/
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { Emoji } = require('./Emoji
|
|
3
|
+
const { Emoji } = require('./Emoji');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents a custom emoji.
|
|
7
|
-
*
|
|
8
7
|
* @extends {Emoji}
|
|
9
8
|
*/
|
|
10
9
|
class ApplicationEmoji extends Emoji {
|
|
@@ -13,7 +12,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* The application this emoji originates from
|
|
16
|
-
*
|
|
17
15
|
* @type {ClientApplication}
|
|
18
16
|
*/
|
|
19
17
|
this.application = application;
|
|
@@ -26,7 +24,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
26
24
|
if (data.user) {
|
|
27
25
|
/**
|
|
28
26
|
* The user who created this emoji
|
|
29
|
-
*
|
|
30
27
|
* @type {User}
|
|
31
28
|
*/
|
|
32
29
|
this.author = this.client.users._add(data.user);
|
|
@@ -35,7 +32,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
35
32
|
if ('managed' in data) {
|
|
36
33
|
/**
|
|
37
34
|
* Whether this emoji is managed by an external service. Always `false` for application emojis
|
|
38
|
-
*
|
|
39
35
|
* @type {false}
|
|
40
36
|
*/
|
|
41
37
|
this.managed = data.managed;
|
|
@@ -44,7 +40,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
44
40
|
if ('require_colons' in data) {
|
|
45
41
|
/**
|
|
46
42
|
* Whether this emoji requires colons surrounding it. Always `true` for application emojis
|
|
47
|
-
*
|
|
48
43
|
* @type {true}
|
|
49
44
|
*/
|
|
50
45
|
this.requiresColons = data.require_colons;
|
|
@@ -53,7 +48,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
53
48
|
if ('available' in data) {
|
|
54
49
|
/**
|
|
55
50
|
* Whether this emoji is available. Always `true` for application emojis
|
|
56
|
-
*
|
|
57
51
|
* @type {true}
|
|
58
52
|
*/
|
|
59
53
|
this.available = data.available;
|
|
@@ -62,23 +56,20 @@ class ApplicationEmoji extends Emoji {
|
|
|
62
56
|
|
|
63
57
|
/**
|
|
64
58
|
* Fetches the author for this emoji
|
|
65
|
-
*
|
|
66
59
|
* @returns {Promise<User>}
|
|
67
60
|
*/
|
|
68
|
-
|
|
61
|
+
fetchAuthor() {
|
|
69
62
|
return this.application.emojis.fetchAuthor(this);
|
|
70
63
|
}
|
|
71
64
|
|
|
72
65
|
/**
|
|
73
66
|
* Data for editing an emoji.
|
|
74
|
-
*
|
|
75
67
|
* @typedef {Object} ApplicationEmojiEditOptions
|
|
76
68
|
* @property {string} [name] The name of the emoji
|
|
77
69
|
*/
|
|
78
70
|
|
|
79
71
|
/**
|
|
80
72
|
* Edits the emoji.
|
|
81
|
-
*
|
|
82
73
|
* @param {ApplicationEmojiEditOptions} options The options to provide
|
|
83
74
|
* @returns {Promise<ApplicationEmoji>}
|
|
84
75
|
* @example
|
|
@@ -87,23 +78,21 @@ class ApplicationEmoji extends Emoji {
|
|
|
87
78
|
* .then(emoji => console.log(`Edited emoji ${emoji}`))
|
|
88
79
|
* .catch(console.error);
|
|
89
80
|
*/
|
|
90
|
-
|
|
81
|
+
edit(options) {
|
|
91
82
|
return this.application.emojis.edit(this.id, options);
|
|
92
83
|
}
|
|
93
84
|
|
|
94
85
|
/**
|
|
95
86
|
* Sets the name of the emoji.
|
|
96
|
-
*
|
|
97
87
|
* @param {string} name The new name for the emoji
|
|
98
88
|
* @returns {Promise<ApplicationEmoji>}
|
|
99
89
|
*/
|
|
100
|
-
|
|
90
|
+
setName(name) {
|
|
101
91
|
return this.edit({ name });
|
|
102
92
|
}
|
|
103
93
|
|
|
104
94
|
/**
|
|
105
95
|
* Deletes the emoji.
|
|
106
|
-
*
|
|
107
96
|
* @returns {Promise<ApplicationEmoji>}
|
|
108
97
|
*/
|
|
109
98
|
async delete() {
|
|
@@ -113,7 +102,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
113
102
|
|
|
114
103
|
/**
|
|
115
104
|
* Whether this emoji is the same as another one.
|
|
116
|
-
*
|
|
117
105
|
* @param {ApplicationEmoji|APIEmoji} other The emoji to compare it to
|
|
118
106
|
* @returns {boolean}
|
|
119
107
|
*/
|
|
@@ -135,7 +123,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
135
123
|
|
|
136
124
|
/**
|
|
137
125
|
* The emoji's name
|
|
138
|
-
*
|
|
139
126
|
* @name name
|
|
140
127
|
* @memberof ApplicationEmoji
|
|
141
128
|
* @instance
|
|
@@ -145,7 +132,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
145
132
|
|
|
146
133
|
/**
|
|
147
134
|
* Whether the emoji is animated
|
|
148
|
-
*
|
|
149
135
|
* @name animated
|
|
150
136
|
* @memberof ApplicationEmoji
|
|
151
137
|
* @instance
|
|
@@ -155,7 +141,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
155
141
|
|
|
156
142
|
/**
|
|
157
143
|
* Returns a URL for the emoji.
|
|
158
|
-
*
|
|
159
144
|
* @method imageURL
|
|
160
145
|
* @memberof ApplicationEmoji
|
|
161
146
|
* @instance
|
|
@@ -165,7 +150,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
165
150
|
|
|
166
151
|
/**
|
|
167
152
|
* The time the emoji was created at
|
|
168
|
-
*
|
|
169
153
|
* @name createdAt
|
|
170
154
|
* @memberof ApplicationEmoji
|
|
171
155
|
* @instance
|
|
@@ -175,7 +159,6 @@ class ApplicationEmoji extends Emoji {
|
|
|
175
159
|
|
|
176
160
|
/**
|
|
177
161
|
* The timestamp the emoji was created at
|
|
178
|
-
*
|
|
179
162
|
* @name createdTimestamp
|
|
180
163
|
* @memberof ApplicationEmoji
|
|
181
164
|
* @instance
|
|
@@ -183,4 +166,4 @@ class ApplicationEmoji extends Emoji {
|
|
|
183
166
|
* @readonly
|
|
184
167
|
*/
|
|
185
168
|
|
|
186
|
-
exports
|
|
169
|
+
module.exports = ApplicationEmoji;
|
|
@@ -7,42 +7,36 @@ class ApplicationRoleConnectionMetadata {
|
|
|
7
7
|
constructor(data) {
|
|
8
8
|
/**
|
|
9
9
|
* The name of this metadata field
|
|
10
|
-
*
|
|
11
10
|
* @type {string}
|
|
12
11
|
*/
|
|
13
12
|
this.name = data.name;
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* The name localizations for this metadata field
|
|
17
|
-
*
|
|
18
16
|
* @type {?LocalizationMap}
|
|
19
17
|
*/
|
|
20
18
|
this.nameLocalizations = data.name_localizations ?? null;
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* The description of this metadata field
|
|
24
|
-
*
|
|
25
22
|
* @type {string}
|
|
26
23
|
*/
|
|
27
24
|
this.description = data.description;
|
|
28
25
|
|
|
29
26
|
/**
|
|
30
27
|
* The description localizations for this metadata field
|
|
31
|
-
*
|
|
32
28
|
* @type {?LocalizationMap}
|
|
33
29
|
*/
|
|
34
30
|
this.descriptionLocalizations = data.description_localizations ?? null;
|
|
35
31
|
|
|
36
32
|
/**
|
|
37
33
|
* The dictionary key for this metadata field
|
|
38
|
-
*
|
|
39
34
|
* @type {string}
|
|
40
35
|
*/
|
|
41
36
|
this.key = data.key;
|
|
42
37
|
|
|
43
38
|
/**
|
|
44
39
|
* The type of this metadata field
|
|
45
|
-
*
|
|
46
40
|
* @type {ApplicationRoleConnectionMetadataType}
|
|
47
41
|
*/
|
|
48
42
|
this.type = data.type;
|