lolka.js 0.1.4 → 0.3.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 +25 -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/voice/VoiceConnection.js +420 -0
- 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 +230 -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 +2432 -1773
- package/typings/index.d.ts +2432 -1773
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { Collection } = require('@discordjs/collection');
|
|
4
4
|
const { ComponentType } = require('discord-api-types/v10');
|
|
5
|
-
const { DiscordjsTypeError, ErrorCodes } = require('../errors
|
|
5
|
+
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {Object} ModalSelectedMentionables
|
|
@@ -12,40 +12,30 @@ const { DiscordjsTypeError, ErrorCodes } = require('../errors/index.js');
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Represents the serialized fields from a modal submit interaction
|
|
16
16
|
*/
|
|
17
|
-
class
|
|
18
|
-
constructor(
|
|
17
|
+
class ModalSubmitFields {
|
|
18
|
+
constructor(components, resolved) {
|
|
19
19
|
/**
|
|
20
|
-
* The
|
|
20
|
+
* The components within the modal
|
|
21
21
|
*
|
|
22
|
-
* @
|
|
23
|
-
* @type {Client}
|
|
24
|
-
* @readonly
|
|
22
|
+
* @type {Array<ActionRowModalData|LabelModalData|TextDisplayModalData>}
|
|
25
23
|
*/
|
|
26
|
-
|
|
24
|
+
this.components = components;
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* The interaction resolved data
|
|
30
28
|
*
|
|
31
|
-
* @name
|
|
29
|
+
* @name ModalSubmitFields#resolved
|
|
32
30
|
* @type {?Readonly<BaseInteractionResolvedData>}
|
|
33
31
|
*/
|
|
34
32
|
Object.defineProperty(this, 'resolved', { value: resolved ? Object.freeze(resolved) : null });
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
|
-
* The
|
|
38
|
-
*
|
|
39
|
-
* @type {Array<ActionRowModalData|LabelModalData|TextDisplayModalData>}
|
|
40
|
-
*/
|
|
41
|
-
this.data = components;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The bottom-level components of the interaction
|
|
45
|
-
*
|
|
35
|
+
* The extracted fields from the modal
|
|
46
36
|
* @type {Collection<string, ModalData>}
|
|
47
37
|
*/
|
|
48
|
-
this.
|
|
38
|
+
this.fields = components.reduce((accumulator, next) => {
|
|
49
39
|
// For legacy support of action rows
|
|
50
40
|
if ('components' in next) {
|
|
51
41
|
for (const component of next.components) accumulator.set(component.customId, component);
|
|
@@ -61,17 +51,20 @@ class ModalComponentResolver {
|
|
|
61
51
|
}
|
|
62
52
|
|
|
63
53
|
/**
|
|
64
|
-
* Gets a
|
|
65
|
-
*
|
|
66
|
-
* @
|
|
54
|
+
* Gets a field given a custom id from a component
|
|
55
|
+
* @param {string} customId The custom id of the component
|
|
56
|
+
* @param {ComponentType} [type] The type of the component
|
|
67
57
|
* @returns {ModalData}
|
|
68
58
|
*/
|
|
69
|
-
|
|
70
|
-
const
|
|
59
|
+
getField(customId, type) {
|
|
60
|
+
const field = this.fields.get(customId);
|
|
61
|
+
if (!field) throw new DiscordjsTypeError(ErrorCodes.ModalSubmitInteractionFieldNotFound, customId);
|
|
71
62
|
|
|
72
|
-
if (
|
|
63
|
+
if (type !== undefined && type !== field.type) {
|
|
64
|
+
throw new DiscordjsTypeError(ErrorCodes.ModalSubmitInteractionFieldType, customId, field.type, type);
|
|
65
|
+
}
|
|
73
66
|
|
|
74
|
-
return
|
|
67
|
+
return field;
|
|
75
68
|
}
|
|
76
69
|
|
|
77
70
|
/**
|
|
@@ -79,30 +72,29 @@ class ModalComponentResolver {
|
|
|
79
72
|
*
|
|
80
73
|
* @param {string} customId The custom id of the component.
|
|
81
74
|
* @param {ComponentType[]} allowedTypes The allowed types of the component.
|
|
82
|
-
* @param {string[]} properties The properties to check for `required`.
|
|
75
|
+
* @param {string[]} properties The properties to check for for `required`.
|
|
83
76
|
* @param {boolean} required Whether to throw an error if the component value(s) are not found.
|
|
84
77
|
* @returns {ModalData} The option, if found.
|
|
85
78
|
* @private
|
|
86
79
|
*/
|
|
87
80
|
_getTypedComponent(customId, allowedTypes, properties, required) {
|
|
88
|
-
const component = this.
|
|
81
|
+
const component = this.getField(customId);
|
|
89
82
|
if (!allowedTypes.includes(component.type)) {
|
|
90
83
|
throw new DiscordjsTypeError(
|
|
91
|
-
ErrorCodes.
|
|
84
|
+
ErrorCodes.ModalSubmitInteractionFieldNotFound,
|
|
92
85
|
customId,
|
|
93
86
|
component.type,
|
|
94
87
|
allowedTypes.join(', '),
|
|
95
88
|
);
|
|
96
89
|
} else if (required && properties.every(prop => component[prop] === null || component[prop] === undefined)) {
|
|
97
|
-
throw new DiscordjsTypeError(ErrorCodes.
|
|
90
|
+
throw new DiscordjsTypeError(ErrorCodes.ModalSubmitInteractionFieldEmpty, customId, component.type);
|
|
98
91
|
}
|
|
99
92
|
|
|
100
93
|
return component;
|
|
101
94
|
}
|
|
102
95
|
|
|
103
96
|
/**
|
|
104
|
-
* Gets the value of a text input component
|
|
105
|
-
*
|
|
97
|
+
* Gets the value of a text input component given a custom id
|
|
106
98
|
* @param {string} customId The custom id of the text input component
|
|
107
99
|
* @returns {string}
|
|
108
100
|
*/
|
|
@@ -111,7 +103,7 @@ class ModalComponentResolver {
|
|
|
111
103
|
}
|
|
112
104
|
|
|
113
105
|
/**
|
|
114
|
-
* Gets the values of a string select component
|
|
106
|
+
* Gets the values of a string select component given a custom id
|
|
115
107
|
*
|
|
116
108
|
* @param {string} customId The custom id of the string select component
|
|
117
109
|
* @returns {string[]}
|
|
@@ -160,7 +152,8 @@ class ModalComponentResolver {
|
|
|
160
152
|
* @param {string} customId The custom id of the component
|
|
161
153
|
* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty
|
|
162
154
|
* @param {ChannelType[]} [channelTypes=[]] The allowed types of channels. If empty, all channel types are allowed.
|
|
163
|
-
* @returns {?Collection<Snowflake, GuildChannel|ThreadChannel|APIChannel>} The selected channels,
|
|
155
|
+
* @returns {?Collection<Snowflake, GuildChannel|ThreadChannel|APIChannel>} The selected channels,
|
|
156
|
+
* or null if none were selected and not required
|
|
164
157
|
*/
|
|
165
158
|
getSelectedChannels(customId, required = false, channelTypes = []) {
|
|
166
159
|
const component = this._getTypedComponent(customId, [ComponentType.ChannelSelect], ['channels'], required);
|
|
@@ -185,7 +178,8 @@ class ModalComponentResolver {
|
|
|
185
178
|
* Gets members component
|
|
186
179
|
*
|
|
187
180
|
* @param {string} customId The custom id of the component
|
|
188
|
-
* @returns {?Collection<Snowflake, GuildMember|APIGuildMember>} The selected members,
|
|
181
|
+
* @returns {?Collection<Snowflake, GuildMember|APIGuildMember>} The selected members,
|
|
182
|
+
* or null if none were selected or the users were not present in the guild
|
|
189
183
|
*/
|
|
190
184
|
getSelectedMembers(customId) {
|
|
191
185
|
const component = this._getTypedComponent(
|
|
@@ -266,4 +260,4 @@ class ModalComponentResolver {
|
|
|
266
260
|
}
|
|
267
261
|
}
|
|
268
262
|
|
|
269
|
-
exports
|
|
263
|
+
module.exports = ModalSubmitFields;
|
|
@@ -2,29 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
const { Collection } = require('@discordjs/collection');
|
|
4
4
|
const { lazy } = require('@discordjs/util');
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const {
|
|
5
|
+
const BaseInteraction = require('./BaseInteraction');
|
|
6
|
+
const InteractionWebhook = require('./InteractionWebhook');
|
|
7
|
+
const ModalSubmitFields = require('./ModalSubmitFields');
|
|
8
|
+
const InteractionResponses = require('./interfaces/InteractionResponses');
|
|
9
|
+
const { transformResolved } = require('../util/Util');
|
|
10
10
|
|
|
11
|
-
const getMessage = lazy(() => require('./Message
|
|
12
|
-
const getAttachment = lazy(() => require('./Attachment
|
|
11
|
+
const getMessage = lazy(() => require('./Message').Message);
|
|
12
|
+
const getAttachment = lazy(() => require('./Attachment'));
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @typedef {Object} BaseModalData
|
|
16
|
-
* @property {ComponentType} type The component type of the
|
|
17
|
-
* @property {number} id The id of the
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @typedef {BaseModalData} SelectMenuModalData
|
|
22
|
-
* @property {string} customId The custom id of the component
|
|
23
|
-
* @property {string[]} values The values of the component
|
|
24
|
-
* @property {Collection<Snowflake, GuildMember|APIGuildMember>} [members] The resolved members
|
|
25
|
-
* @property {Collection<Snowflake, User|APIUser>} [users] The resolved users
|
|
26
|
-
* @property {Collection<Snowflake, Role|APIRole>} [roles] The resolved roles
|
|
27
|
-
* @property {Collection<Snowflake, BaseChannel|APIChannel>} [channels] The resolved channels
|
|
16
|
+
* @property {ComponentType} type The component type of the field
|
|
17
|
+
* @property {number} id The id of the field
|
|
28
18
|
*/
|
|
29
19
|
|
|
30
20
|
/**
|
|
@@ -54,8 +44,18 @@ const getAttachment = lazy(() => require('./Attachment.js').Attachment);
|
|
|
54
44
|
|
|
55
45
|
/**
|
|
56
46
|
* @typedef {BaseModalData} TextInputModalData
|
|
57
|
-
* @property {string} customId The custom id of the
|
|
58
|
-
* @property {string} value The value of the
|
|
47
|
+
* @property {string} customId The custom id of the field
|
|
48
|
+
* @property {string} value The value of the field
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {BaseModalData} SelectMenuModalData
|
|
53
|
+
* @property {string} customId The custom id of the field
|
|
54
|
+
* @property {string[]} values The values of the field
|
|
55
|
+
* @property {Collection<Snowflake, GuildMember|APIGuildMember>} [members] The resolved members
|
|
56
|
+
* @property {Collection<Snowflake, User|APIUser>} [users] The resolved users
|
|
57
|
+
* @property {Collection<Snowflake, Role|APIRole>} [roles] The resolved roles
|
|
58
|
+
* @property {Collection<Snowflake, BaseChannel|APIChannel>} [channels] The resolved channels
|
|
59
59
|
*/
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -63,7 +63,8 @@ const getAttachment = lazy(() => require('./Attachment.js').Attachment);
|
|
|
63
63
|
*/
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* @typedef {SelectMenuModalData|TextInputModalData|FileUploadModalData|RadioGroupModalData|
|
|
66
|
+
* @typedef {SelectMenuModalData|TextInputModalData|FileUploadModalData|RadioGroupModalData|
|
|
67
|
+
* CheckboxGroupModalData|CheckboxModalData} ModalData
|
|
67
68
|
*/
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -78,7 +79,6 @@ const getAttachment = lazy(() => require('./Attachment.js').Attachment);
|
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* Represents a modal interaction
|
|
81
|
-
*
|
|
82
82
|
* @extends {BaseInteraction}
|
|
83
83
|
* @implements {InteractionResponses}
|
|
84
84
|
*/
|
|
@@ -87,7 +87,6 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
87
87
|
super(client, data);
|
|
88
88
|
/**
|
|
89
89
|
* The custom id of the modal.
|
|
90
|
-
*
|
|
91
90
|
* @type {string}
|
|
92
91
|
*/
|
|
93
92
|
this.customId = data.data.custom_id;
|
|
@@ -95,7 +94,6 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
95
94
|
if ('message' in data) {
|
|
96
95
|
/**
|
|
97
96
|
* The message associated with this interaction
|
|
98
|
-
*
|
|
99
97
|
* @type {?Message}
|
|
100
98
|
*/
|
|
101
99
|
this.message = this.channel?.messages._add(data.message) ?? new (getMessage())(this.client, data.message);
|
|
@@ -106,38 +104,44 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
106
104
|
/**
|
|
107
105
|
* The components within the modal
|
|
108
106
|
*
|
|
109
|
-
* @type {
|
|
107
|
+
* @type {Array<ActionRowModalData | LabelModalData | TextDisplayModalData>}
|
|
108
|
+
*/
|
|
109
|
+
this.components = data.data.components?.map(component =>
|
|
110
|
+
ModalSubmitInteraction.transformComponent(component, data.data.resolved, {
|
|
111
|
+
client: this.client,
|
|
112
|
+
guild: this.guild,
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The fields within the modal
|
|
118
|
+
* @type {ModalSubmitFields}
|
|
110
119
|
*/
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
113
|
-
data.data.components?.map(component => this.transformComponent(component, data.data.resolved)),
|
|
120
|
+
this.fields = new ModalSubmitFields(
|
|
121
|
+
this.components,
|
|
114
122
|
transformResolved({ client: this.client, guild: this.guild, channel: this.channel }, data.data.resolved),
|
|
115
123
|
);
|
|
116
124
|
|
|
117
125
|
/**
|
|
118
126
|
* Whether the reply to this interaction has been deferred
|
|
119
|
-
*
|
|
120
127
|
* @type {boolean}
|
|
121
128
|
*/
|
|
122
129
|
this.deferred = false;
|
|
123
130
|
|
|
124
131
|
/**
|
|
125
132
|
* Whether this interaction has already been replied to
|
|
126
|
-
*
|
|
127
133
|
* @type {boolean}
|
|
128
134
|
*/
|
|
129
135
|
this.replied = false;
|
|
130
136
|
|
|
131
137
|
/**
|
|
132
138
|
* Whether the reply to this interaction is ephemeral
|
|
133
|
-
*
|
|
134
139
|
* @type {?boolean}
|
|
135
140
|
*/
|
|
136
141
|
this.ephemeral = null;
|
|
137
142
|
|
|
138
143
|
/**
|
|
139
144
|
* An associated interaction webhook, can be used to further interact with this interaction
|
|
140
|
-
*
|
|
141
145
|
* @type {InteractionWebhook}
|
|
142
146
|
*/
|
|
143
147
|
this.webhook = new InteractionWebhook(this.client, this.applicationId, this.token);
|
|
@@ -145,18 +149,19 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
145
149
|
|
|
146
150
|
/**
|
|
147
151
|
* Transforms component data to discord.js-compatible data
|
|
148
|
-
*
|
|
149
152
|
* @param {*} rawComponent The data to transform
|
|
150
|
-
* @param {APIInteractionDataResolved} resolved The resolved data for the interaction
|
|
153
|
+
* @param {APIInteractionDataResolved} [resolved] The resolved data for the interaction
|
|
154
|
+
* @param {*} [extra] Extra data required for the transformation
|
|
151
155
|
* @returns {ModalData[]}
|
|
152
|
-
* @private
|
|
153
156
|
*/
|
|
154
|
-
transformComponent(rawComponent, resolved) {
|
|
157
|
+
static transformComponent(rawComponent, resolved, { client, guild } = {}) {
|
|
155
158
|
if ('components' in rawComponent) {
|
|
156
159
|
return {
|
|
157
160
|
type: rawComponent.type,
|
|
158
161
|
id: rawComponent.id,
|
|
159
|
-
components: rawComponent.components.map(component =>
|
|
162
|
+
components: rawComponent.components.map(component =>
|
|
163
|
+
this.transformComponent(component, resolved, { client, guild }),
|
|
164
|
+
),
|
|
160
165
|
};
|
|
161
166
|
}
|
|
162
167
|
|
|
@@ -164,7 +169,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
164
169
|
return {
|
|
165
170
|
type: rawComponent.type,
|
|
166
171
|
id: rawComponent.id,
|
|
167
|
-
component: this.transformComponent(rawComponent.component, resolved),
|
|
172
|
+
component: this.transformComponent(rawComponent.component, resolved, { client, guild }),
|
|
168
173
|
};
|
|
169
174
|
}
|
|
170
175
|
|
|
@@ -180,6 +185,8 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
180
185
|
|
|
181
186
|
if (rawComponent.values) {
|
|
182
187
|
data.values = rawComponent.values;
|
|
188
|
+
|
|
189
|
+
/* eslint-disable max-depth */
|
|
183
190
|
if (resolved) {
|
|
184
191
|
const { members, users, channels, roles, attachments } = resolved;
|
|
185
192
|
const valueSet = new Set(rawComponent.values);
|
|
@@ -189,7 +196,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
189
196
|
|
|
190
197
|
for (const [id, user] of Object.entries(users)) {
|
|
191
198
|
if (valueSet.has(id)) {
|
|
192
|
-
data.users.set(id,
|
|
199
|
+
data.users.set(id, client.users._add(user));
|
|
193
200
|
}
|
|
194
201
|
}
|
|
195
202
|
}
|
|
@@ -199,7 +206,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
199
206
|
|
|
200
207
|
for (const [id, apiChannel] of Object.entries(channels)) {
|
|
201
208
|
if (valueSet.has(id)) {
|
|
202
|
-
data.channels.set(id,
|
|
209
|
+
data.channels.set(id, client.channels._add(apiChannel, guild) ?? apiChannel);
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
212
|
}
|
|
@@ -210,7 +217,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
210
217
|
for (const [id, member] of Object.entries(members)) {
|
|
211
218
|
if (valueSet.has(id)) {
|
|
212
219
|
const user = users?.[id];
|
|
213
|
-
data.members.set(id,
|
|
220
|
+
data.members.set(id, guild?.members._add({ user, ...member }) ?? member);
|
|
214
221
|
}
|
|
215
222
|
}
|
|
216
223
|
}
|
|
@@ -220,7 +227,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
220
227
|
|
|
221
228
|
for (const [id, role] of Object.entries(roles)) {
|
|
222
229
|
if (valueSet.has(id)) {
|
|
223
|
-
data.roles.set(id,
|
|
230
|
+
data.roles.set(id, guild?.roles._add(role) ?? role);
|
|
224
231
|
}
|
|
225
232
|
}
|
|
226
233
|
}
|
|
@@ -234,6 +241,8 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
234
241
|
}
|
|
235
242
|
}
|
|
236
243
|
}
|
|
244
|
+
|
|
245
|
+
/* eslint-enable max-depth */
|
|
237
246
|
}
|
|
238
247
|
|
|
239
248
|
return data;
|
|
@@ -241,7 +250,6 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
241
250
|
|
|
242
251
|
/**
|
|
243
252
|
* Whether this is from a {@link MessageComponentInteraction}.
|
|
244
|
-
*
|
|
245
253
|
* @returns {boolean}
|
|
246
254
|
*/
|
|
247
255
|
isFromMessage() {
|
|
@@ -249,26 +257,19 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
249
257
|
}
|
|
250
258
|
|
|
251
259
|
// These are here only for documentation purposes - they are implemented by InteractionResponses
|
|
252
|
-
|
|
260
|
+
/* eslint-disable no-empty-function */
|
|
253
261
|
deferReply() {}
|
|
254
|
-
|
|
255
262
|
reply() {}
|
|
256
|
-
|
|
257
263
|
fetchReply() {}
|
|
258
|
-
|
|
259
264
|
editReply() {}
|
|
260
|
-
|
|
261
265
|
deleteReply() {}
|
|
262
|
-
|
|
263
266
|
followUp() {}
|
|
264
|
-
|
|
265
267
|
deferUpdate() {}
|
|
266
|
-
|
|
267
268
|
update() {}
|
|
268
|
-
|
|
269
|
+
sendPremiumRequired() {}
|
|
269
270
|
launchActivity() {}
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
InteractionResponses.applyToClass(ModalSubmitInteraction, 'showModal');
|
|
273
274
|
|
|
274
|
-
exports
|
|
275
|
+
module.exports = ModalSubmitInteraction;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { Routes } = require('discord-api-types/v10');
|
|
4
|
+
const BaseGuildTextChannel = require('./BaseGuildTextChannel');
|
|
5
|
+
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a guild news channel on Discord.
|
|
9
|
+
* @extends {BaseGuildTextChannel}
|
|
10
|
+
*/
|
|
11
|
+
class NewsChannel extends BaseGuildTextChannel {
|
|
12
|
+
/**
|
|
13
|
+
* Adds the target to this channel's followers.
|
|
14
|
+
* @param {TextChannelResolvable} channel The channel where the webhook should be created
|
|
15
|
+
* @param {string} [reason] Reason for creating the webhook
|
|
16
|
+
* @returns {Promise<NewsChannel>}
|
|
17
|
+
* @example
|
|
18
|
+
* if (channel.type === ChannelType.GuildAnnouncement) {
|
|
19
|
+
* channel.addFollower('222197033908436994', 'Important announcements')
|
|
20
|
+
* .then(() => console.log('Added follower'))
|
|
21
|
+
* .catch(console.error);
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
async addFollower(channel, reason) {
|
|
25
|
+
const channelId = this.guild.channels.resolveId(channel);
|
|
26
|
+
if (!channelId) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
|
|
27
|
+
await this.client.rest.post(Routes.channelFollowers(this.id), { body: { webhook_channel_id: channelId }, reason });
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = NewsChannel;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const BaseGuild = require('./BaseGuild');
|
|
4
|
+
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A partial guild received when using {@link GuildManager#fetch} to fetch multiple guilds.
|
|
8
|
-
*
|
|
9
8
|
* @extends {BaseGuild}
|
|
10
9
|
*/
|
|
11
10
|
class OAuth2Guild extends BaseGuild {
|
|
@@ -14,18 +13,16 @@ class OAuth2Guild extends BaseGuild {
|
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Whether the client user is the owner of the guild
|
|
17
|
-
*
|
|
18
16
|
* @type {boolean}
|
|
19
17
|
*/
|
|
20
18
|
this.owner = data.owner;
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* The permissions that the client user has in this guild
|
|
24
|
-
*
|
|
25
22
|
* @type {Readonly<PermissionsBitField>}
|
|
26
23
|
*/
|
|
27
24
|
this.permissions = new PermissionsBitField(BigInt(data.permissions)).freeze();
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
exports
|
|
28
|
+
module.exports = OAuth2Guild;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const
|
|
5
|
-
const {
|
|
6
|
-
const
|
|
3
|
+
const { BaseChannel } = require('./BaseChannel');
|
|
4
|
+
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
|
5
|
+
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
6
|
+
const PartialGroupDMMessageManager = require('../managers/PartialGroupDMMessageManager');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Represents a Partial Group DM Channel on Discord.
|
|
10
|
-
*
|
|
11
10
|
* @extends {BaseChannel}
|
|
12
11
|
* @implements {TextBasedChannel}
|
|
13
12
|
*/
|
|
@@ -20,35 +19,30 @@ class PartialGroupDMChannel extends BaseChannel {
|
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* The name of this Group DM Channel
|
|
23
|
-
*
|
|
24
22
|
* @type {?string}
|
|
25
23
|
*/
|
|
26
24
|
this.name = data.name;
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* The hash of the channel icon
|
|
30
|
-
*
|
|
31
28
|
* @type {?string}
|
|
32
29
|
*/
|
|
33
30
|
this.icon = data.icon ?? null;
|
|
34
31
|
|
|
35
32
|
/**
|
|
36
33
|
* Recipient data received in a {@link PartialGroupDMChannel}.
|
|
37
|
-
*
|
|
38
34
|
* @typedef {Object} PartialRecipient
|
|
39
35
|
* @property {string} username The username of the recipient
|
|
40
36
|
*/
|
|
41
37
|
|
|
42
38
|
/**
|
|
43
39
|
* The recipients of this Group DM Channel.
|
|
44
|
-
*
|
|
45
40
|
* @type {PartialRecipient[]}
|
|
46
41
|
*/
|
|
47
42
|
this.recipients = data.recipients ?? [];
|
|
48
43
|
|
|
49
44
|
/**
|
|
50
45
|
* A manager of the messages belonging to this channel
|
|
51
|
-
*
|
|
52
46
|
* @type {PartialGroupDMMessageManager}
|
|
53
47
|
*/
|
|
54
48
|
this.messages = new PartialGroupDMMessageManager(this);
|
|
@@ -56,7 +50,6 @@ class PartialGroupDMChannel extends BaseChannel {
|
|
|
56
50
|
if ('owner_id' in data) {
|
|
57
51
|
/**
|
|
58
52
|
* The user id of the owner of this Group DM Channel
|
|
59
|
-
*
|
|
60
53
|
* @type {?Snowflake}
|
|
61
54
|
*/
|
|
62
55
|
this.ownerId = data.owner_id;
|
|
@@ -67,7 +60,6 @@ class PartialGroupDMChannel extends BaseChannel {
|
|
|
67
60
|
if ('last_message_id' in data) {
|
|
68
61
|
/**
|
|
69
62
|
* The channel's last message id, if one was sent
|
|
70
|
-
*
|
|
71
63
|
* @type {?Snowflake}
|
|
72
64
|
*/
|
|
73
65
|
this.lastMessageId = data.last_message_id;
|
|
@@ -78,7 +70,6 @@ class PartialGroupDMChannel extends BaseChannel {
|
|
|
78
70
|
if ('last_pin_timestamp' in data) {
|
|
79
71
|
/**
|
|
80
72
|
* The timestamp when the last pinned message was pinned, if there was one
|
|
81
|
-
*
|
|
82
73
|
* @type {?number}
|
|
83
74
|
*/
|
|
84
75
|
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
|
@@ -89,17 +80,18 @@ class PartialGroupDMChannel extends BaseChannel {
|
|
|
89
80
|
|
|
90
81
|
/**
|
|
91
82
|
* The URL to this channel's icon.
|
|
92
|
-
*
|
|
93
83
|
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
94
84
|
* @returns {?string}
|
|
95
85
|
*/
|
|
96
86
|
iconURL(options = {}) {
|
|
97
|
-
return
|
|
87
|
+
return (
|
|
88
|
+
this.icon &&
|
|
89
|
+
(/^https?:\/\//.test(this.icon) ? this.icon : this.client.rest.cdn.channelIcon(this.id, this.icon, options))
|
|
90
|
+
);
|
|
98
91
|
}
|
|
99
92
|
|
|
100
93
|
/**
|
|
101
94
|
* Fetches the owner of this Group DM Channel.
|
|
102
|
-
*
|
|
103
95
|
* @param {BaseFetchOptions} [options] The options for fetching the user
|
|
104
96
|
* @returns {Promise<User>}
|
|
105
97
|
*/
|
|
@@ -120,18 +112,14 @@ class PartialGroupDMChannel extends BaseChannel {
|
|
|
120
112
|
}
|
|
121
113
|
|
|
122
114
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
|
123
|
-
|
|
124
|
-
/* eslint-disable getter-return */
|
|
115
|
+
/* eslint-disable no-empty-function */
|
|
125
116
|
get lastMessage() {}
|
|
126
|
-
|
|
127
117
|
get lastPinAt() {}
|
|
128
|
-
|
|
129
118
|
createMessageComponentCollector() {}
|
|
130
|
-
|
|
131
119
|
awaitMessageComponent() {}
|
|
132
120
|
}
|
|
133
121
|
|
|
134
|
-
TextBasedChannel.applyToClass(PartialGroupDMChannel, [
|
|
122
|
+
TextBasedChannel.applyToClass(PartialGroupDMChannel, true, [
|
|
135
123
|
'bulkDelete',
|
|
136
124
|
'send',
|
|
137
125
|
'sendTyping',
|
|
@@ -143,4 +131,4 @@ TextBasedChannel.applyToClass(PartialGroupDMChannel, [
|
|
|
143
131
|
'setNSFW',
|
|
144
132
|
]);
|
|
145
133
|
|
|
146
|
-
exports
|
|
134
|
+
module.exports = PartialGroupDMChannel;
|