@ovencord/discord.js 14.16.3
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/LICENSE +191 -0
- package/README.md +148 -0
- package/package.json +73 -0
- package/src/client/Client.ts +967 -0
- package/src/client/actions/Action.ts +141 -0
- package/src/client/actions/ActionsManager.ts +138 -0
- package/src/client/actions/ChannelCreate.ts +21 -0
- package/src/client/actions/ChannelDelete.ts +20 -0
- package/src/client/actions/ChannelUpdate.ts +38 -0
- package/src/client/actions/GuildChannelsPositionUpdate.ts +17 -0
- package/src/client/actions/GuildEmojiCreate.ts +17 -0
- package/src/client/actions/GuildEmojiDelete.ts +16 -0
- package/src/client/actions/GuildEmojiUpdate.ts +17 -0
- package/src/client/actions/GuildEmojisUpdate.ts +30 -0
- package/src/client/actions/GuildMemberRemove.ts +29 -0
- package/src/client/actions/GuildMemberUpdate.ts +41 -0
- package/src/client/actions/GuildRoleCreate.ts +23 -0
- package/src/client/actions/GuildRoleDelete.ts +26 -0
- package/src/client/actions/GuildRolesPositionUpdate.ts +17 -0
- package/src/client/actions/GuildScheduledEventDelete.ts +28 -0
- package/src/client/actions/GuildScheduledEventUserAdd.ts +29 -0
- package/src/client/actions/GuildScheduledEventUserRemove.ts +29 -0
- package/src/client/actions/GuildSoundboardSoundDelete.ts +26 -0
- package/src/client/actions/GuildStickerCreate.ts +17 -0
- package/src/client/actions/GuildStickerDelete.ts +16 -0
- package/src/client/actions/GuildStickerUpdate.ts +17 -0
- package/src/client/actions/GuildStickersUpdate.ts +30 -0
- package/src/client/actions/GuildUpdate.ts +30 -0
- package/src/client/actions/InteractionCreate.ts +104 -0
- package/src/client/actions/MessageCreate.ts +38 -0
- package/src/client/actions/MessageDelete.ts +29 -0
- package/src/client/actions/MessageDeleteBulk.ts +45 -0
- package/src/client/actions/MessagePollVoteAdd.ts +37 -0
- package/src/client/actions/MessagePollVoteRemove.ts +35 -0
- package/src/client/actions/MessageReactionAdd.ts +68 -0
- package/src/client/actions/MessageReactionRemove.ts +47 -0
- package/src/client/actions/MessageReactionRemoveAll.ts +30 -0
- package/src/client/actions/MessageReactionRemoveEmoji.ts +25 -0
- package/src/client/actions/MessageUpdate.ts +22 -0
- package/src/client/actions/StageInstanceCreate.ts +25 -0
- package/src/client/actions/StageInstanceDelete.ts +28 -0
- package/src/client/actions/StageInstanceUpdate.ts +27 -0
- package/src/client/actions/ThreadCreate.ts +22 -0
- package/src/client/actions/ThreadMembersUpdate.ts +45 -0
- package/src/client/actions/TypingStart.ts +26 -0
- package/src/client/actions/UserUpdate.ts +33 -0
- package/src/client/voice/ClientVoiceManager.ts +46 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.ts +17 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.ts +18 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.ts +21 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.ts +22 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.ts +14 -0
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.ts +18 -0
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.ts +15 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_CREATE.ts +34 -0
- package/src/client/websocket/handlers/GUILD_DELETE.ts +36 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.ts +15 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.ts +40 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.ts +17 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.ts +21 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.ts +17 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.ts +24 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.ts +18 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.ts +4 -0
- package/src/client/websocket/handlers/INVITE_CREATE.ts +20 -0
- package/src/client/websocket/handlers/INVITE_DELETE.ts +23 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.ts +42 -0
- package/src/client/websocket/handlers/RATE_LIMITED.ts +23 -0
- package/src/client/websocket/handlers/READY.ts +29 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.ts +24 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.ts +14 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.ts +16 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/THREAD_CREATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_DELETE.ts +17 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.ts +50 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.ts +25 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/TYPING_START.ts +4 -0
- package/src/client/websocket/handlers/USER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.ts +16 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.ts +5 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.ts +37 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/index.ts +74 -0
- package/src/errors/DJSError.ts +50 -0
- package/src/errors/ErrorCodes.ts +277 -0
- package/src/errors/Messages.ts +155 -0
- package/src/errors/index.ts +6 -0
- package/src/index.ts +241 -0
- package/src/managers/ApplicationCommandManager.ts +303 -0
- package/src/managers/ApplicationCommandPermissionsManager.ts +453 -0
- package/src/managers/ApplicationEmojiManager.ts +149 -0
- package/src/managers/AutoModerationRuleManager.ts +307 -0
- package/src/managers/BaseManager.ts +13 -0
- package/src/managers/CachedManager.ts +56 -0
- package/src/managers/CategoryChannelChildManager.ts +81 -0
- package/src/managers/ChannelManager.ts +194 -0
- package/src/managers/DMMessageManager.ts +15 -0
- package/src/managers/DataManager.ts +38 -0
- package/src/managers/EntitlementManager.ts +182 -0
- package/src/managers/GuildApplicationCommandManager.ts +29 -0
- package/src/managers/GuildBanManager.ts +221 -0
- package/src/managers/GuildChannelManager.ts +552 -0
- package/src/managers/GuildEmojiManager.ts +262 -0
- package/src/managers/GuildEmojiRoleManager.ts +134 -0
- package/src/managers/GuildForumThreadManager.ts +84 -0
- package/src/managers/GuildInviteManager.ts +236 -0
- package/src/managers/GuildManager.ts +265 -0
- package/src/managers/GuildMemberManager.ts +619 -0
- package/src/managers/GuildMemberRoleManager.ts +230 -0
- package/src/managers/GuildMessageManager.ts +31 -0
- package/src/managers/GuildScheduledEventManager.ts +330 -0
- package/src/managers/GuildSoundboardSoundManager.ts +157 -0
- package/src/managers/GuildStickerManager.ts +192 -0
- package/src/managers/GuildTextThreadManager.ts +91 -0
- package/src/managers/MessageManager.ts +352 -0
- package/src/managers/PartialGroupDMMessageManager.ts +15 -0
- package/src/managers/PermissionOverwriteManager.ts +174 -0
- package/src/managers/PollAnswerVoterManager.ts +59 -0
- package/src/managers/PresenceManager.ts +60 -0
- package/src/managers/ReactionManager.ts +72 -0
- package/src/managers/ReactionUserManager.ts +82 -0
- package/src/managers/RoleManager.ts +432 -0
- package/src/managers/StageInstanceManager.ts +166 -0
- package/src/managers/SubscriptionManager.ts +83 -0
- package/src/managers/ThreadManager.ts +210 -0
- package/src/managers/ThreadMemberManager.ts +194 -0
- package/src/managers/UserManager.ts +139 -0
- package/src/managers/VoiceStateManager.ts +61 -0
- package/src/sharding/Shard.ts +513 -0
- package/src/sharding/ShardClientUtil.ts +293 -0
- package/src/sharding/ShardingManager.ts +374 -0
- package/src/structures/ActionRow.ts +31 -0
- package/src/structures/AnnouncementChannel.ts +25 -0
- package/src/structures/AnonymousGuild.ts +110 -0
- package/src/structures/ApplicationCommand.ts +675 -0
- package/src/structures/ApplicationEmoji.ts +189 -0
- package/src/structures/ApplicationRoleConnectionMetadata.ts +54 -0
- package/src/structures/Attachment.ts +189 -0
- package/src/structures/AuthorizingIntegrationOwners.ts +63 -0
- package/src/structures/AutoModerationActionExecution.ts +138 -0
- package/src/structures/AutoModerationRule.ts +325 -0
- package/src/structures/AutocompleteInteraction.ts +115 -0
- package/src/structures/Base.ts +37 -0
- package/src/structures/BaseChannel.ts +188 -0
- package/src/structures/BaseGuild.ts +134 -0
- package/src/structures/BaseGuildEmoji.ts +113 -0
- package/src/structures/BaseGuildTextChannel.ts +230 -0
- package/src/structures/BaseGuildVoiceChannel.ts +270 -0
- package/src/structures/BaseInteraction.ts +393 -0
- package/src/structures/BaseInvite.ts +192 -0
- package/src/structures/BaseSelectMenuComponent.ts +58 -0
- package/src/structures/ButtonComponent.ts +68 -0
- package/src/structures/ButtonInteraction.ts +8 -0
- package/src/structures/CategoryChannel.ts +46 -0
- package/src/structures/ChannelSelectMenuComponent.ts +18 -0
- package/src/structures/ChannelSelectMenuInteraction.ts +34 -0
- package/src/structures/ChatInputCommandInteraction.ts +43 -0
- package/src/structures/ClientApplication.ts +470 -0
- package/src/structures/ClientPresence.ts +87 -0
- package/src/structures/ClientUser.ts +219 -0
- package/src/structures/CommandInteraction.ts +193 -0
- package/src/structures/CommandInteractionOptionResolver.ts +336 -0
- package/src/structures/Component.ts +59 -0
- package/src/structures/ContainerComponent.ts +63 -0
- package/src/structures/ContextMenuCommandInteraction.ts +68 -0
- package/src/structures/DMChannel.ts +148 -0
- package/src/structures/DirectoryChannel.ts +40 -0
- package/src/structures/Embed.ts +251 -0
- package/src/structures/Emoji.ts +61 -0
- package/src/structures/Entitlement.ts +206 -0
- package/src/structures/FileComponent.ts +41 -0
- package/src/structures/ForumChannel.ts +31 -0
- package/src/structures/GroupDMInvite.ts +34 -0
- package/src/structures/Guild.ts +1605 -0
- package/src/structures/GuildAuditLogs.ts +99 -0
- package/src/structures/GuildAuditLogsEntry.ts +557 -0
- package/src/structures/GuildBan.ts +65 -0
- package/src/structures/GuildChannel.ts +515 -0
- package/src/structures/GuildEmoji.ts +159 -0
- package/src/structures/GuildInvite.ts +233 -0
- package/src/structures/GuildMember.ts +643 -0
- package/src/structures/GuildOnboarding.ts +73 -0
- package/src/structures/GuildOnboardingPrompt.ts +93 -0
- package/src/structures/GuildOnboardingPromptOption.ts +100 -0
- package/src/structures/GuildPreview.ts +218 -0
- package/src/structures/GuildPreviewEmoji.ts +28 -0
- package/src/structures/GuildScheduledEvent.ts +593 -0
- package/src/structures/GuildTemplate.ts +229 -0
- package/src/structures/Integration.ts +257 -0
- package/src/structures/IntegrationApplication.ts +84 -0
- package/src/structures/InteractionCallback.ts +86 -0
- package/src/structures/InteractionCallbackResource.ts +57 -0
- package/src/structures/InteractionCallbackResponse.ts +35 -0
- package/src/structures/InteractionCollector.ts +260 -0
- package/src/structures/InteractionWebhook.ts +65 -0
- package/src/structures/InviteGuild.ts +22 -0
- package/src/structures/LabelComponent.ts +51 -0
- package/src/structures/MediaChannel.ts +8 -0
- package/src/structures/MediaGalleryComponent.ts +31 -0
- package/src/structures/MediaGalleryItem.ts +54 -0
- package/src/structures/MentionableSelectMenuComponent.ts +8 -0
- package/src/structures/MentionableSelectMenuInteraction.ts +76 -0
- package/src/structures/Message.ts +1202 -0
- package/src/structures/MessageCollector.ts +155 -0
- package/src/structures/MessageComponentInteraction.ts +132 -0
- package/src/structures/MessageContextMenuCommandInteraction.ts +18 -0
- package/src/structures/MessageMentions.ts +327 -0
- package/src/structures/MessagePayload.ts +325 -0
- package/src/structures/MessageReaction.ts +219 -0
- package/src/structures/ModalComponentResolver.ts +237 -0
- package/src/structures/ModalSubmitInteraction.ts +260 -0
- package/src/structures/OAuth2Guild.ts +30 -0
- package/src/structures/PartialGroupDMChannel.ts +151 -0
- package/src/structures/PermissionOverwrites.ts +222 -0
- package/src/structures/Poll.ts +195 -0
- package/src/structures/PollAnswer.ts +100 -0
- package/src/structures/Presence.ts +448 -0
- package/src/structures/PrimaryEntryPointCommandInteraction.ts +8 -0
- package/src/structures/ReactionCollector.ts +245 -0
- package/src/structures/ReactionEmoji.ts +30 -0
- package/src/structures/Role.ts +543 -0
- package/src/structures/RoleSelectMenuComponent.ts +8 -0
- package/src/structures/RoleSelectMenuInteraction.ts +34 -0
- package/src/structures/SKU.ts +62 -0
- package/src/structures/SectionComponent.ts +44 -0
- package/src/structures/SeparatorComponent.ts +29 -0
- package/src/structures/SoundboardSound.ts +176 -0
- package/src/structures/StageChannel.ts +118 -0
- package/src/structures/StageInstance.ts +173 -0
- package/src/structures/Sticker.ts +300 -0
- package/src/structures/StickerPack.ts +111 -0
- package/src/structures/StringSelectMenuComponent.ts +18 -0
- package/src/structures/StringSelectMenuInteraction.ts +21 -0
- package/src/structures/Subscription.ts +138 -0
- package/src/structures/Team.ts +131 -0
- package/src/structures/TeamMember.ts +77 -0
- package/src/structures/TextChannel.ts +33 -0
- package/src/structures/TextDisplayComponent.ts +18 -0
- package/src/structures/TextInputComponent.ts +28 -0
- package/src/structures/ThreadChannel.ts +680 -0
- package/src/structures/ThreadMember.ts +125 -0
- package/src/structures/ThreadOnlyChannel.ts +276 -0
- package/src/structures/ThumbnailComponent.ts +51 -0
- package/src/structures/Typing.ts +81 -0
- package/src/structures/UnfurledMediaItem.ts +33 -0
- package/src/structures/User.ts +511 -0
- package/src/structures/UserContextMenuCommandInteraction.ts +28 -0
- package/src/structures/UserSelectMenuComponent.ts +8 -0
- package/src/structures/UserSelectMenuInteraction.ts +54 -0
- package/src/structures/VoiceChannel.ts +119 -0
- package/src/structures/VoiceChannelEffect.ts +92 -0
- package/src/structures/VoiceRegion.ts +52 -0
- package/src/structures/VoiceState.ts +346 -0
- package/src/structures/Webhook.ts +526 -0
- package/src/structures/WelcomeChannel.ts +67 -0
- package/src/structures/WelcomeScreen.ts +53 -0
- package/src/structures/Widget.ts +110 -0
- package/src/structures/WidgetMember.ts +124 -0
- package/src/structures/interfaces/Application.ts +179 -0
- package/src/structures/interfaces/Collector.ts +372 -0
- package/src/structures/interfaces/InteractionResponses.ts +384 -0
- package/src/structures/interfaces/TextBasedChannel.ts +430 -0
- package/src/util/APITypes.ts +690 -0
- package/src/util/ActivityFlagsBitField.ts +26 -0
- package/src/util/ApplicationFlagsBitField.ts +43 -0
- package/src/util/AttachmentFlagsBitField.ts +26 -0
- package/src/util/BitField.ts +178 -0
- package/src/util/ChannelFlagsBitField.ts +43 -0
- package/src/util/Channels.ts +165 -0
- package/src/util/Colors.ts +72 -0
- package/src/util/Components.ts +285 -0
- package/src/util/Constants.ts +251 -0
- package/src/util/DataResolver.ts +146 -0
- package/src/util/Enums.ts +10 -0
- package/src/util/Events.ts +178 -0
- package/src/util/GuildMemberFlagsBitField.ts +43 -0
- package/src/util/IntentsBitField.ts +35 -0
- package/src/util/InviteFlagsBitField.ts +26 -0
- package/src/util/Invites.ts +27 -0
- package/src/util/LimitedCollection.ts +73 -0
- package/src/util/MessageFlagsBitField.ts +43 -0
- package/src/util/Options.ts +215 -0
- package/src/util/Partials.ts +50 -0
- package/src/util/PermissionsBitField.ts +113 -0
- package/src/util/RoleFlagsBitField.ts +26 -0
- package/src/util/SKUFlagsBitField.ts +26 -0
- package/src/util/ShardEvents.ts +26 -0
- package/src/util/Status.ts +16 -0
- package/src/util/Sweepers.ts +532 -0
- package/src/util/Symbols.ts +1 -0
- package/src/util/SystemChannelFlagsBitField.ts +45 -0
- package/src/util/ThreadMemberFlagsBitField.ts +33 -0
- package/src/util/Transformers.ts +123 -0
- package/src/util/UserFlagsBitField.ts +33 -0
- package/src/util/Util.ts +519 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { ComponentType } from 'discord-api-types/v10';
|
|
3
|
+
import { DiscordjsTypeError, ErrorCodes } from '../errors/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} ModalSelectedMentionables
|
|
7
|
+
* @property {Collection<Snowflake, User>} users The selected users
|
|
8
|
+
* @property {Collection<Snowflake, GuildMember | APIGuildMember>} members The selected members
|
|
9
|
+
* @property {Collection<Snowflake, Role | APIRole>} roles The selected roles
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A resolver for modal submit components
|
|
14
|
+
*/
|
|
15
|
+
export class ModalComponentResolver {
|
|
16
|
+
public client: any;
|
|
17
|
+
public data: any;
|
|
18
|
+
public hoistedComponents: any;
|
|
19
|
+
constructor(client, components, resolved) {
|
|
20
|
+
/**
|
|
21
|
+
* The client that instantiated this.
|
|
22
|
+
*
|
|
23
|
+
* @name ModalComponentResolver#client
|
|
24
|
+
* @type {Client}
|
|
25
|
+
* @readonly
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(this, 'client', { value: client });
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The interaction resolved data
|
|
31
|
+
*
|
|
32
|
+
* @name ModalComponentResolver#resolved
|
|
33
|
+
* @type {?Readonly<BaseInteractionResolvedData>}
|
|
34
|
+
*/
|
|
35
|
+
Object.defineProperty(this, 'resolved', { value: resolved ? Object.freeze(resolved) : null });
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The components within the modal
|
|
39
|
+
*
|
|
40
|
+
* @type {Array<ActionRowModalData|LabelModalData|TextDisplayModalData>}
|
|
41
|
+
*/
|
|
42
|
+
this.data = components;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The bottom-level components of the interaction
|
|
46
|
+
*
|
|
47
|
+
* @type {Collection<string, ModalData>}
|
|
48
|
+
*/
|
|
49
|
+
this.hoistedComponents = components.reduce((accumulator, next) => {
|
|
50
|
+
// For legacy support of action rows
|
|
51
|
+
if ('components' in next) {
|
|
52
|
+
for (const component of next.components) accumulator.set(component.customId, component);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// For label components
|
|
56
|
+
if ('component' in next) {
|
|
57
|
+
accumulator.set(next.component.customId, next.component);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return accumulator;
|
|
61
|
+
}, new Collection());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Gets a component by custom id.
|
|
66
|
+
*
|
|
67
|
+
* @property {string} customId The custom id of the component.
|
|
68
|
+
* @returns {ModalData}
|
|
69
|
+
*/
|
|
70
|
+
getComponent(customId) {
|
|
71
|
+
const component = this.hoistedComponents.get(customId);
|
|
72
|
+
|
|
73
|
+
if (!component) throw new DiscordjsTypeError(ErrorCodes.ModalSubmitInteractionComponentNotFound, customId);
|
|
74
|
+
|
|
75
|
+
return component;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Gets a component by custom id and property and checks its type.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} customId The custom id of the component.
|
|
82
|
+
* @param {ComponentType[]} allowedTypes The allowed types of the component.
|
|
83
|
+
* @param {string[]} properties The properties to check for for `required`.
|
|
84
|
+
* @param {boolean} required Whether to throw an error if the component value(s) are not found.
|
|
85
|
+
* @returns {ModalData} The option, if found.
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
_getTypedComponent(customId, allowedTypes, properties, required) {
|
|
89
|
+
const component = this.getComponent(customId);
|
|
90
|
+
if (!allowedTypes.includes(component.type)) {
|
|
91
|
+
throw new DiscordjsTypeError(
|
|
92
|
+
ErrorCodes.ModalSubmitInteractionComponentType,
|
|
93
|
+
customId,
|
|
94
|
+
component.type,
|
|
95
|
+
allowedTypes.join(', '),
|
|
96
|
+
);
|
|
97
|
+
} else if (required && properties.every(prop => component[prop] === null || component[prop] === undefined)) {
|
|
98
|
+
throw new DiscordjsTypeError(ErrorCodes.ModalSubmitInteractionComponentEmpty, customId, component.type);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return component;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Gets the value of a text input component
|
|
106
|
+
*
|
|
107
|
+
* @param {string} customId The custom id of the text input component
|
|
108
|
+
* @returns {string}
|
|
109
|
+
*/
|
|
110
|
+
getTextInputValue(customId) {
|
|
111
|
+
return this._getTypedComponent(customId, [ComponentType.TextInput]).value;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Gets the values of a string select component
|
|
116
|
+
*
|
|
117
|
+
* @param {string} customId The custom id of the string select component
|
|
118
|
+
* @returns {string[]}
|
|
119
|
+
*/
|
|
120
|
+
getStringSelectValues(customId) {
|
|
121
|
+
return this._getTypedComponent(customId, [ComponentType.StringSelect]).values;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Gets users component
|
|
126
|
+
*
|
|
127
|
+
* @param {string} customId The custom id of the component
|
|
128
|
+
* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty
|
|
129
|
+
* @returns {?Collection<Snowflake, User>} The selected users, or null if none were selected and not required
|
|
130
|
+
*/
|
|
131
|
+
getSelectedUsers(customId, required = false) {
|
|
132
|
+
const component = this._getTypedComponent(
|
|
133
|
+
customId,
|
|
134
|
+
[ComponentType.UserSelect, ComponentType.MentionableSelect],
|
|
135
|
+
['users'],
|
|
136
|
+
required,
|
|
137
|
+
);
|
|
138
|
+
return component.users ?? null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Gets roles component
|
|
143
|
+
*
|
|
144
|
+
* @param {string} customId The custom id of the component
|
|
145
|
+
* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty
|
|
146
|
+
* @returns {?Collection<Snowflake, Role|APIRole>} The selected roles, or null if none were selected and not required
|
|
147
|
+
*/
|
|
148
|
+
getSelectedRoles(customId, required = false) {
|
|
149
|
+
const component = this._getTypedComponent(
|
|
150
|
+
customId,
|
|
151
|
+
[ComponentType.RoleSelect, ComponentType.MentionableSelect],
|
|
152
|
+
['roles'],
|
|
153
|
+
required,
|
|
154
|
+
);
|
|
155
|
+
return component.roles ?? null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Gets channels component
|
|
160
|
+
*
|
|
161
|
+
* @param {string} customId The custom id of the component
|
|
162
|
+
* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty
|
|
163
|
+
* @param {ChannelType[]} [channelTypes=[]] The allowed types of channels. If empty, all channel types are allowed.
|
|
164
|
+
* @returns {?Collection<Snowflake, GuildChannel|ThreadChannel|APIChannel>} The selected channels, or null if none were selected and not required
|
|
165
|
+
*/
|
|
166
|
+
getSelectedChannels(customId, required = false, channelTypes = []) {
|
|
167
|
+
const component = this._getTypedComponent(customId, [ComponentType.ChannelSelect], ['channels'], required);
|
|
168
|
+
const channels = component.channels;
|
|
169
|
+
if (channels && channelTypes.length > 0) {
|
|
170
|
+
for (const channel of channels.values()) {
|
|
171
|
+
if (!channelTypes.includes(channel.type)) {
|
|
172
|
+
throw new DiscordjsTypeError(
|
|
173
|
+
ErrorCodes.ModalSubmitInteractionComponentInvalidChannelType,
|
|
174
|
+
customId,
|
|
175
|
+
channel.type,
|
|
176
|
+
channelTypes.join(', '),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return channels ?? null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Gets members component
|
|
187
|
+
*
|
|
188
|
+
* @param {string} customId The custom id of the component
|
|
189
|
+
* @returns {?Collection<Snowflake, GuildMember|APIGuildMember>} The selected members, or null if none were selected or the users were not present in the guild
|
|
190
|
+
*/
|
|
191
|
+
getSelectedMembers(customId) {
|
|
192
|
+
const component = this._getTypedComponent(
|
|
193
|
+
customId,
|
|
194
|
+
[ComponentType.UserSelect, ComponentType.MentionableSelect],
|
|
195
|
+
['members'],
|
|
196
|
+
false,
|
|
197
|
+
);
|
|
198
|
+
return component.members ?? null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Gets mentionables component
|
|
203
|
+
*
|
|
204
|
+
* @param {string} customId The custom id of the component
|
|
205
|
+
* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty
|
|
206
|
+
* @returns {?ModalSelectedMentionables} The selected mentionables, or null if none were selected and not required
|
|
207
|
+
*/
|
|
208
|
+
getSelectedMentionables(customId, required = false) {
|
|
209
|
+
const component = this._getTypedComponent(
|
|
210
|
+
customId,
|
|
211
|
+
[ComponentType.MentionableSelect],
|
|
212
|
+
['users', 'members', 'roles'],
|
|
213
|
+
required,
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
if (component.users || component.members || component.roles) {
|
|
217
|
+
return {
|
|
218
|
+
users: component.users ?? new Collection(),
|
|
219
|
+
members: component.members ?? new Collection(),
|
|
220
|
+
roles: component.roles ?? new Collection(),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Gets file upload component
|
|
229
|
+
*
|
|
230
|
+
* @param {string} customId The custom id of the component
|
|
231
|
+
* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty
|
|
232
|
+
* @returns {?Collection<Snowflake, Attachment>} The uploaded files, or null if none were uploaded and not required
|
|
233
|
+
*/
|
|
234
|
+
getUploadedFiles(customId, required = false) {
|
|
235
|
+
return this._getTypedComponent(customId, [ComponentType.FileUpload], ['attachments'], required).attachments ?? null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { lazy } from '@ovencord/util';
|
|
3
|
+
import { transformResolved } from '../util/Util.js';
|
|
4
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
5
|
+
import { InteractionWebhook } from './InteractionWebhook.js';
|
|
6
|
+
import { ModalComponentResolver } from './ModalComponentResolver.js';
|
|
7
|
+
import { InteractionResponses } from './interfaces/InteractionResponses.js';
|
|
8
|
+
|
|
9
|
+
const getMessage = lazy(() => require('./Message.js').Message);
|
|
10
|
+
const getAttachment = lazy(() => require('./Attachment.js').Attachment);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object} BaseModalData
|
|
14
|
+
* @property {ComponentType} type The component type of the component
|
|
15
|
+
* @property {number} id The id of the component
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {BaseModalData} SelectMenuModalData
|
|
20
|
+
* @property {string} customId The custom id of the component
|
|
21
|
+
* @property {string[]} values The values of the component
|
|
22
|
+
* @property {Collection<Snowflake, GuildMember|APIGuildMember>} [members] The resolved members
|
|
23
|
+
* @property {Collection<Snowflake, User|APIUser>} [users] The resolved users
|
|
24
|
+
* @property {Collection<Snowflake, Role|APIRole>} [roles] The resolved roles
|
|
25
|
+
* @property {Collection<Snowflake, BaseChannel|APIChannel>} [channels] The resolved channels
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {BaseModalData} FileUploadModalData
|
|
30
|
+
* @property {string} customId The custom id of the file upload
|
|
31
|
+
* @property {Snowflake[]} values The values of the file upload
|
|
32
|
+
* @property {Collection<Snowflake, Attachment>} [attachments] The resolved attachments
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {BaseModalData} TextInputModalData
|
|
37
|
+
* @property {string} customId The custom id of the component
|
|
38
|
+
* @property {string} value The value of the component
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {BaseModalData} TextDisplayModalData
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {SelectMenuModalData|TextInputModalData|FileUploadModalData} ModalData
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {BaseModalData} LabelModalData
|
|
51
|
+
* @property {ModalData} component The component within the label
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {BaseModalData} ActionRowModalData
|
|
56
|
+
* @property {TextInputModalData[]} components The components of this action row
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Represents a modal interaction
|
|
61
|
+
*
|
|
62
|
+
* @extends {BaseInteraction}
|
|
63
|
+
* @implements {InteractionResponses}
|
|
64
|
+
*/
|
|
65
|
+
export class ModalSubmitInteraction extends BaseInteraction {
|
|
66
|
+
public client: any;
|
|
67
|
+
public customId: any;
|
|
68
|
+
public message: any;
|
|
69
|
+
public components: any;
|
|
70
|
+
public deferred: any;
|
|
71
|
+
public replied: any;
|
|
72
|
+
public ephemeral: any;
|
|
73
|
+
public webhook: any;
|
|
74
|
+
constructor(client, data) {
|
|
75
|
+
super(client, data);
|
|
76
|
+
/**
|
|
77
|
+
* The custom id of the modal.
|
|
78
|
+
*
|
|
79
|
+
* @type {string}
|
|
80
|
+
*/
|
|
81
|
+
this.customId = data.data.custom_id;
|
|
82
|
+
|
|
83
|
+
if ('message' in data) {
|
|
84
|
+
/**
|
|
85
|
+
* The message associated with this interaction
|
|
86
|
+
*
|
|
87
|
+
* @type {?Message}
|
|
88
|
+
*/
|
|
89
|
+
this.message = this.channel?.messages._add(data.message) ?? new (getMessage())(this.client, data.message);
|
|
90
|
+
} else {
|
|
91
|
+
this.message = null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The components within the modal
|
|
96
|
+
*
|
|
97
|
+
* @type {ModalComponentResolver}
|
|
98
|
+
*/
|
|
99
|
+
this.components = new ModalComponentResolver(
|
|
100
|
+
this.client,
|
|
101
|
+
data.data.components?.map(component => this.transformComponent(component, data.data.resolved)),
|
|
102
|
+
transformResolved({ client: this.client, guild: this.guild, channel: this.channel }, data.data.resolved),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Whether the reply to this interaction has been deferred
|
|
107
|
+
*
|
|
108
|
+
* @type {boolean}
|
|
109
|
+
*/
|
|
110
|
+
this.deferred = false;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Whether this interaction has already been replied to
|
|
114
|
+
*
|
|
115
|
+
* @type {boolean}
|
|
116
|
+
*/
|
|
117
|
+
this.replied = false;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether the reply to this interaction is ephemeral
|
|
121
|
+
*
|
|
122
|
+
* @type {?boolean}
|
|
123
|
+
*/
|
|
124
|
+
this.ephemeral = null;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* An associated interaction webhook, can be used to further interact with this interaction
|
|
128
|
+
*
|
|
129
|
+
* @type {InteractionWebhook}
|
|
130
|
+
*/
|
|
131
|
+
this.webhook = new InteractionWebhook(this.client, this.applicationId, this.token);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Transforms component data to discord.js-compatible data
|
|
136
|
+
*
|
|
137
|
+
* @param {*} rawComponent The data to transform
|
|
138
|
+
* @param {APIInteractionDataResolved} resolved The resolved data for the interaction
|
|
139
|
+
* @returns {ModalData[]}
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
transformComponent(rawComponent, resolved) {
|
|
143
|
+
if ('components' in rawComponent) {
|
|
144
|
+
return {
|
|
145
|
+
type: rawComponent.type,
|
|
146
|
+
id: rawComponent.id,
|
|
147
|
+
components: rawComponent.components.map(component => this.transformComponent(component, resolved)),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if ('component' in rawComponent) {
|
|
152
|
+
return {
|
|
153
|
+
type: rawComponent.type,
|
|
154
|
+
id: rawComponent.id,
|
|
155
|
+
component: this.transformComponent(rawComponent.component, resolved),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const data = {
|
|
160
|
+
type: rawComponent.type,
|
|
161
|
+
id: rawComponent.id,
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// Text display components do not have custom ids.
|
|
165
|
+
if ('custom_id' in rawComponent) data.customId = rawComponent.custom_id;
|
|
166
|
+
|
|
167
|
+
if ('value' in rawComponent) data.value = rawComponent.value;
|
|
168
|
+
|
|
169
|
+
if (rawComponent.values) {
|
|
170
|
+
data.values = rawComponent.values;
|
|
171
|
+
if (resolved) {
|
|
172
|
+
const { members, users, channels, roles, attachments } = resolved;
|
|
173
|
+
const valueSet = new Set(rawComponent.values);
|
|
174
|
+
|
|
175
|
+
if (users) {
|
|
176
|
+
data.users = new Collection();
|
|
177
|
+
|
|
178
|
+
for (const [id, user] of Object.entries(users)) {
|
|
179
|
+
if (valueSet.has(id)) {
|
|
180
|
+
data.users.set(id, this.client.users._add(user));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (channels) {
|
|
186
|
+
data.channels = new Collection();
|
|
187
|
+
|
|
188
|
+
for (const [id, apiChannel] of Object.entries(channels)) {
|
|
189
|
+
if (valueSet.has(id)) {
|
|
190
|
+
data.channels.set(id, this.client.channels._add(apiChannel, this.guild) ?? apiChannel);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (members) {
|
|
196
|
+
data.members = new Collection();
|
|
197
|
+
|
|
198
|
+
for (const [id, member] of Object.entries(members)) {
|
|
199
|
+
if (valueSet.has(id)) {
|
|
200
|
+
const user = users?.[id];
|
|
201
|
+
data.members.set(id, this.guild?.members._add({ user, ...member }) ?? member);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (roles) {
|
|
207
|
+
data.roles = new Collection();
|
|
208
|
+
|
|
209
|
+
for (const [id, role] of Object.entries(roles)) {
|
|
210
|
+
if (valueSet.has(id)) {
|
|
211
|
+
data.roles.set(id, this.guild?.roles._add(role) ?? role);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (attachments) {
|
|
217
|
+
data.attachments = new Collection();
|
|
218
|
+
for (const [id, attachment] of Object.entries(attachments)) {
|
|
219
|
+
if (valueSet.has(id)) {
|
|
220
|
+
data.attachments.set(id, new (getAttachment())(attachment));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return data;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Whether this is from a {@link MessageComponentInteraction}.
|
|
232
|
+
*
|
|
233
|
+
* @returns {boolean}
|
|
234
|
+
*/
|
|
235
|
+
isFromMessage() {
|
|
236
|
+
return Boolean(this.message);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// These are here only for documentation purposes - they are implemented by InteractionResponses
|
|
240
|
+
|
|
241
|
+
deferReply() {}
|
|
242
|
+
|
|
243
|
+
reply() {}
|
|
244
|
+
|
|
245
|
+
fetchReply() {}
|
|
246
|
+
|
|
247
|
+
editReply() {}
|
|
248
|
+
|
|
249
|
+
deleteReply() {}
|
|
250
|
+
|
|
251
|
+
followUp() {}
|
|
252
|
+
|
|
253
|
+
deferUpdate() {}
|
|
254
|
+
|
|
255
|
+
update() {}
|
|
256
|
+
|
|
257
|
+
launchActivity() {}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
InteractionResponses.applyToClass(ModalSubmitInteraction, 'showModal');
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PermissionsBitField } from '../util/PermissionsBitField.js';
|
|
2
|
+
import { BaseGuild } from './BaseGuild.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A partial guild received when using {@link GuildManager#fetch} to fetch multiple guilds.
|
|
6
|
+
*
|
|
7
|
+
* @extends {BaseGuild}
|
|
8
|
+
*/
|
|
9
|
+
export class OAuth2Guild extends BaseGuild {
|
|
10
|
+
public client: any;
|
|
11
|
+
public owner: any;
|
|
12
|
+
public permissions: any;
|
|
13
|
+
constructor(client, data) {
|
|
14
|
+
super(client, data);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Whether the client user is the owner of the guild
|
|
18
|
+
*
|
|
19
|
+
* @type {boolean}
|
|
20
|
+
*/
|
|
21
|
+
this.owner = data.owner;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The permissions that the client user has in this guild
|
|
25
|
+
*
|
|
26
|
+
* @type {Readonly<PermissionsBitField>}
|
|
27
|
+
*/
|
|
28
|
+
this.permissions = new PermissionsBitField(BigInt(data.permissions)).freeze();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { DiscordjsError, ErrorCodes } from '../errors/index.js';
|
|
2
|
+
import { PartialGroupDMMessageManager } from '../managers/PartialGroupDMMessageManager.js';
|
|
3
|
+
import { BaseChannel } from './BaseChannel.js';
|
|
4
|
+
import { TextBasedChannel } from './interfaces/TextBasedChannel.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a Partial Group DM Channel on Discord.
|
|
8
|
+
*
|
|
9
|
+
* @extends {BaseChannel}
|
|
10
|
+
* @implements {TextBasedChannel}
|
|
11
|
+
*/
|
|
12
|
+
export class PartialGroupDMChannel extends BaseChannel {
|
|
13
|
+
public client: any;
|
|
14
|
+
public flags: any;
|
|
15
|
+
public name: any;
|
|
16
|
+
public icon: any;
|
|
17
|
+
public recipients: any;
|
|
18
|
+
public messages: any;
|
|
19
|
+
public ownerId: any;
|
|
20
|
+
public lastMessageId: any;
|
|
21
|
+
public lastPinTimestamp: any;
|
|
22
|
+
constructor(client, data) {
|
|
23
|
+
super(client, data);
|
|
24
|
+
|
|
25
|
+
// No flags are present when fetching partial group DM channels.
|
|
26
|
+
this.flags = null;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The name of this Group DM Channel
|
|
30
|
+
*
|
|
31
|
+
* @type {?string}
|
|
32
|
+
*/
|
|
33
|
+
this.name = data.name;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The hash of the channel icon
|
|
37
|
+
*
|
|
38
|
+
* @type {?string}
|
|
39
|
+
*/
|
|
40
|
+
this.icon = data.icon ?? null;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Recipient data received in a {@link PartialGroupDMChannel}.
|
|
44
|
+
*
|
|
45
|
+
* @typedef {Object} PartialRecipient
|
|
46
|
+
* @property {string} username The username of the recipient
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The recipients of this Group DM Channel.
|
|
51
|
+
*
|
|
52
|
+
* @type {PartialRecipient[]}
|
|
53
|
+
*/
|
|
54
|
+
this.recipients = data.recipients ?? [];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A manager of the messages belonging to this channel
|
|
58
|
+
*
|
|
59
|
+
* @type {PartialGroupDMMessageManager}
|
|
60
|
+
*/
|
|
61
|
+
this.messages = new PartialGroupDMMessageManager(this);
|
|
62
|
+
|
|
63
|
+
if ('owner_id' in data) {
|
|
64
|
+
/**
|
|
65
|
+
* The user id of the owner of this Group DM Channel
|
|
66
|
+
*
|
|
67
|
+
* @type {?Snowflake}
|
|
68
|
+
*/
|
|
69
|
+
this.ownerId = data.owner_id;
|
|
70
|
+
} else {
|
|
71
|
+
this.ownerId ??= null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if ('last_message_id' in data) {
|
|
75
|
+
/**
|
|
76
|
+
* The channel's last message id, if one was sent
|
|
77
|
+
*
|
|
78
|
+
* @type {?Snowflake}
|
|
79
|
+
*/
|
|
80
|
+
this.lastMessageId = data.last_message_id;
|
|
81
|
+
} else {
|
|
82
|
+
this.lastMessageId ??= null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if ('last_pin_timestamp' in data) {
|
|
86
|
+
/**
|
|
87
|
+
* The timestamp when the last pinned message was pinned, if there was one
|
|
88
|
+
*
|
|
89
|
+
* @type {?number}
|
|
90
|
+
*/
|
|
91
|
+
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
|
92
|
+
} else {
|
|
93
|
+
this.lastPinTimestamp ??= null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The URL to this channel's icon.
|
|
99
|
+
*
|
|
100
|
+
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
101
|
+
* @returns {?string}
|
|
102
|
+
*/
|
|
103
|
+
iconURL(options = {}) {
|
|
104
|
+
return this.icon && this.client.rest.cdn.channelIcon(this.id, this.icon, options);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Fetches the owner of this Group DM Channel.
|
|
109
|
+
*
|
|
110
|
+
* @param {BaseFetchOptions} [options] The options for fetching the user
|
|
111
|
+
* @returns {Promise<User>}
|
|
112
|
+
*/
|
|
113
|
+
async fetchOwner(options) {
|
|
114
|
+
if (!this.ownerId) {
|
|
115
|
+
throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'group DM');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return this.client.users.fetch(this.ownerId, options);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async delete() {
|
|
122
|
+
throw new DiscordjsError(ErrorCodes.DeleteGroupDMChannel);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async fetch() {
|
|
126
|
+
throw new DiscordjsError(ErrorCodes.FetchGroupDMChannel);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
|
130
|
+
|
|
131
|
+
/* eslint-disable getter-return */
|
|
132
|
+
get lastMessage() {}
|
|
133
|
+
|
|
134
|
+
get lastPinAt() {}
|
|
135
|
+
|
|
136
|
+
createMessageComponentCollector() {}
|
|
137
|
+
|
|
138
|
+
awaitMessageComponent() {}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
TextBasedChannel.applyToClass(PartialGroupDMChannel, [
|
|
142
|
+
'bulkDelete',
|
|
143
|
+
'send',
|
|
144
|
+
'sendTyping',
|
|
145
|
+
'createMessageCollector',
|
|
146
|
+
'awaitMessages',
|
|
147
|
+
'fetchWebhooks',
|
|
148
|
+
'createWebhook',
|
|
149
|
+
'setRateLimitPerUser',
|
|
150
|
+
'setNSFW',
|
|
151
|
+
]);
|