@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,285 @@
|
|
|
1
|
+
import { lazy } from '@ovencord/util';
|
|
2
|
+
import { ComponentType } from 'discord-api-types/v10';
|
|
3
|
+
|
|
4
|
+
// Fixes circular dependencies.
|
|
5
|
+
const getActionRow = lazy(() => require('../structures/ActionRow.js').ActionRow);
|
|
6
|
+
const getButtonComponent = lazy(() => require('../structures/ButtonComponent.js').ButtonComponent);
|
|
7
|
+
const getChannelSelectMenuComponent = lazy(
|
|
8
|
+
() => require('../structures/ChannelSelectMenuComponent.js').ChannelSelectMenuComponent,
|
|
9
|
+
);
|
|
10
|
+
const getComponent = lazy(() => require('../structures/Component.js').Component);
|
|
11
|
+
const getContainerComponent = lazy(() => require('../structures/ContainerComponent.js').ContainerComponent);
|
|
12
|
+
const getFileComponent = lazy(() => require('../structures/FileComponent.js').FileComponent);
|
|
13
|
+
const getLabelComponent = lazy(() => require('../structures/LabelComponent.js').LabelComponent);
|
|
14
|
+
const getMediaGalleryComponent = lazy(() => require('../structures/MediaGalleryComponent.js').MediaGalleryComponent);
|
|
15
|
+
const getMentionableSelectMenuComponent = lazy(
|
|
16
|
+
() => require('../structures/MentionableSelectMenuComponent.js').MentionableSelectMenuComponent,
|
|
17
|
+
);
|
|
18
|
+
const getRoleSelectMenuComponent = lazy(
|
|
19
|
+
() => require('../structures/RoleSelectMenuComponent.js').RoleSelectMenuComponent,
|
|
20
|
+
);
|
|
21
|
+
const getSectionComponent = lazy(() => require('../structures/SectionComponent.js').SectionComponent);
|
|
22
|
+
const getSeparatorComponent = lazy(() => require('../structures/SeparatorComponent.js').SeparatorComponent);
|
|
23
|
+
const getStringSelectMenuComponent = lazy(
|
|
24
|
+
() => require('../structures/StringSelectMenuComponent.js').StringSelectMenuComponent,
|
|
25
|
+
);
|
|
26
|
+
const getTextDisplayComponent = lazy(() => require('../structures/TextDisplayComponent.js').TextDisplayComponent);
|
|
27
|
+
const getTextInputComponent = lazy(() => require('../structures/TextInputComponent.js').TextInputComponent);
|
|
28
|
+
const getThumbnailComponent = lazy(() => require('../structures/ThumbnailComponent.js').ThumbnailComponent);
|
|
29
|
+
const getUserSelectMenuComponent = lazy(
|
|
30
|
+
() => require('../structures/UserSelectMenuComponent.js').UserSelectMenuComponent,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {Object} BaseComponentData
|
|
35
|
+
* @property {number} [id] the id of this component
|
|
36
|
+
* @property {ComponentType} type The type of component
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {BaseComponentData} ActionRowData
|
|
41
|
+
* @property {ComponentData[]} components The components in this action row
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {Object} ModalComponentData
|
|
46
|
+
* @property {string} title The title of the modal
|
|
47
|
+
* @property {string} customId The custom id of the modal
|
|
48
|
+
* @property {Array<TextDisplayComponentData|LabelData>} components The components within this modal
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {StringSelectMenuComponentData|TextInputComponentData|UserSelectMenuComponentData|
|
|
53
|
+
* RoleSelectMenuComponentData|MentionableSelectMenuComponentData|ChannelSelectMenuComponentData|FileUploadComponentData} ComponentInLabelData
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @typedef {BaseComponentData} LabelData
|
|
58
|
+
* @property {string} label The label to use
|
|
59
|
+
* @property {string} [description] The optional description for the label
|
|
60
|
+
* @property {ComponentInLabelData} component The component within the label
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {BaseComponentData} ButtonComponentData
|
|
65
|
+
* @property {ButtonStyle} style The style of the button
|
|
66
|
+
* @property {boolean} [disabled] Whether this button is disabled
|
|
67
|
+
* @property {string} label The label of this button
|
|
68
|
+
* @property {APIMessageComponentEmoji} [emoji] The emoji on this button
|
|
69
|
+
* @property {string} [customId] The custom id of the button
|
|
70
|
+
* @property {string} [url] The URL of the button
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @typedef {BaseComponentData} FileUploadComponentData
|
|
75
|
+
* @property {string} customId The custom id of the file upload
|
|
76
|
+
* @property {number} [minValues] The minimum number of files that must be uploaded (0-10)
|
|
77
|
+
* @property {number} [maxValues] The maximum number of files that can be uploaded (1-10)
|
|
78
|
+
* @property {boolean} [required] Whether this component is required in modals
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @typedef {BaseComponentData} BaseSelectMenuComponentData
|
|
83
|
+
* @property {string} customId The custom id of the select menu
|
|
84
|
+
* @property {boolean} [disabled] Whether the select menu is disabled or not
|
|
85
|
+
* @property {number} [maxValues] The maximum amount of options that can be selected
|
|
86
|
+
* @property {number} [minValues] The minimum amount of options that must be selected
|
|
87
|
+
* @property {string} [placeholder] The placeholder of the select menu
|
|
88
|
+
* @property {boolean} [required] Whether this component is required in modals
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @typedef {BaseSelectMenuComponentData} StringSelectMenuComponentData
|
|
93
|
+
* @property {SelectMenuComponentOptionData[]} [options] The options in this select menu
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @typedef {BaseSelectMenuComponentData} UserSelectMenuComponentData
|
|
98
|
+
* @property {APISelectMenuDefaultValue[]} [defaultValues] The default selected values in this select menu
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @typedef {BaseSelectMenuComponentData} RoleSelectMenuComponentData
|
|
103
|
+
* @property {APISelectMenuDefaultValue[]} [defaultValues] The default selected values in this select menu
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @typedef {BaseSelectMenuComponentData} MentionableSelectMenuComponentData
|
|
108
|
+
* @property {APISelectMenuDefaultValue[]} [defaultValues] The default selected values in this select menu
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @typedef {BaseSelectMenuComponentData} ChannelSelectMenuComponentData
|
|
113
|
+
* @property {APISelectMenuDefaultValue[]} [defaultValues] The default selected values in this select menu
|
|
114
|
+
* @property {ChannelType[]} [channelTypes] The types of channels that can be selected
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @typedef {Object} SelectMenuComponentOptionData
|
|
119
|
+
* @property {string} label The label of the option
|
|
120
|
+
* @property {string} value The value of the option
|
|
121
|
+
* @property {string} [description] The description of the option
|
|
122
|
+
* @property {APIMessageComponentEmoji} [emoji] The emoji on the option
|
|
123
|
+
* @property {boolean} [default] Whether this option is selected by default
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @typedef {BaseComponentData} SelectMenuComponentData
|
|
128
|
+
* @property {string} customId The custom id of the select menu
|
|
129
|
+
* @property {boolean} [disabled] Whether the select menu is disabled or not
|
|
130
|
+
* @property {number} [maxValues] The maximum amount of options that can be selected
|
|
131
|
+
* @property {number} [minValues] The minimum amount of options that can be selected
|
|
132
|
+
* @property {SelectMenuComponentOptionData[]} [options] The options in this select menu
|
|
133
|
+
* @property {string} [placeholder] The placeholder of the select menu
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @typedef {ActionRowData|ButtonComponentData|SelectMenuComponentData} MessageComponentData
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @typedef {BaseComponentData} TextInputComponentData
|
|
142
|
+
* @property {string} customId The custom id of the text input
|
|
143
|
+
* @property {TextInputStyle} style The style of the text input
|
|
144
|
+
* @property {number} [minLength] The minimum number of characters that can be entered in the text input
|
|
145
|
+
* @property {number} [maxLength] The maximum number of characters that can be entered in the text input
|
|
146
|
+
* @property {boolean} [required] Whether or not the text input is required or not
|
|
147
|
+
* @property {string} [value] The pre-filled text in the text input
|
|
148
|
+
* @property {string} [placeholder] Placeholder for the text input
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @typedef {Object} UnfurledMediaItemData
|
|
153
|
+
* @property {string} url The url of this media item. Accepts either http:, https: or attachment: protocol
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @typedef {BaseComponentData} ThumbnailComponentData
|
|
158
|
+
* @property {UnfurledMediaItemData} media The media for the thumbnail
|
|
159
|
+
* @property {string} [description] The description of the thumbnail
|
|
160
|
+
* @property {boolean} [spoiler] Whether the thumbnail should be spoilered
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @typedef {BaseComponentData} FileComponentData
|
|
165
|
+
* @property {UnfurledMediaItemData} file The file media in this component
|
|
166
|
+
* @property {boolean} [spoiler] Whether the file should be spoilered
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @typedef {Object} MediaGalleryItemData
|
|
171
|
+
* @property {UnfurledMediaItemData} media The media for the media gallery item
|
|
172
|
+
* @property {string} [description] The description of the media gallery item
|
|
173
|
+
* @property {boolean} [spoiler] Whether the media gallery item should be spoilered
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @typedef {BaseComponentData} MediaGalleryComponentData
|
|
178
|
+
* @property {MediaGalleryItemData[]} items The media gallery items in this media gallery component
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @typedef {BaseComponentData} SeparatorComponentData
|
|
183
|
+
* @property {SeparatorSpacingSize} [spacing] The spacing size of this component
|
|
184
|
+
* @property {boolean} [divider] Whether the separator shows as a divider
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @typedef {BaseComponentData} SectionComponentData
|
|
189
|
+
* @property {Components[]} components The components in this section
|
|
190
|
+
* @property {ButtonComponentData|ThumbnailComponentData} accessory The accessory shown next to this section
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @typedef {BaseComponentData} TextDisplayComponentData
|
|
195
|
+
* @property {string} content The content displayed in this component
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @typedef {ActionRowData|FileComponentData|MediaGalleryComponentData|SectionComponentData|
|
|
200
|
+
* SeparatorComponentData|TextDisplayComponentData} ComponentInContainerData
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @typedef {BaseComponentData} ContainerComponentData
|
|
205
|
+
* @property {ComponentInContainerData} components The components in this container
|
|
206
|
+
* @property {?number} [accentColor] The accent color of this container
|
|
207
|
+
* @property {boolean} [spoiler] Whether the container should be spoilered
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @typedef {ActionRowData|ButtonComponentData|SelectMenuComponentData|TextInputComponentData|
|
|
212
|
+
* ThumbnailComponentData|FileComponentData|MediaGalleryComponentData|SeparatorComponentData|
|
|
213
|
+
* SectionComponentData|TextDisplayComponentData|ContainerComponentData} ComponentData
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @typedef {ActionRow|ContainerComponent|FileComponent|MediaGalleryComponent|
|
|
218
|
+
* SectionComponent|SeparatorComponent|TextDisplayComponent} MessageTopLevelComponent
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
const ComponentTypeToClass = {
|
|
222
|
+
[ComponentType.ActionRow]: getActionRow,
|
|
223
|
+
[ComponentType.Button]: getButtonComponent,
|
|
224
|
+
[ComponentType.StringSelect]: getStringSelectMenuComponent,
|
|
225
|
+
[ComponentType.TextInput]: getTextInputComponent,
|
|
226
|
+
[ComponentType.UserSelect]: getUserSelectMenuComponent,
|
|
227
|
+
[ComponentType.RoleSelect]: getRoleSelectMenuComponent,
|
|
228
|
+
[ComponentType.MentionableSelect]: getMentionableSelectMenuComponent,
|
|
229
|
+
[ComponentType.ChannelSelect]: getChannelSelectMenuComponent,
|
|
230
|
+
[ComponentType.Container]: getContainerComponent,
|
|
231
|
+
[ComponentType.TextDisplay]: getTextDisplayComponent,
|
|
232
|
+
[ComponentType.File]: getFileComponent,
|
|
233
|
+
[ComponentType.MediaGallery]: getMediaGalleryComponent,
|
|
234
|
+
[ComponentType.Section]: getSectionComponent,
|
|
235
|
+
[ComponentType.Separator]: getSeparatorComponent,
|
|
236
|
+
[ComponentType.Thumbnail]: getThumbnailComponent,
|
|
237
|
+
[ComponentType.Label]: getLabelComponent,
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Transforms API data into a component
|
|
242
|
+
*
|
|
243
|
+
* @param {APIMessageComponent|Component} data The data to create the component from
|
|
244
|
+
* @returns {Component}
|
|
245
|
+
* @ignore
|
|
246
|
+
*/
|
|
247
|
+
export function createComponent(data) {
|
|
248
|
+
return data instanceof getComponent() ? data : new (ComponentTypeToClass[data.type]?.() ?? getComponent())(data);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Extracts all interactive components from the component tree
|
|
253
|
+
*
|
|
254
|
+
* @param {Component|APIMessageComponent} component The component to find all interactive components in
|
|
255
|
+
* @returns {Array<Component|APIMessageComponent>}
|
|
256
|
+
* @ignore
|
|
257
|
+
*/
|
|
258
|
+
export function extractInteractiveComponents(component) {
|
|
259
|
+
switch (component.type) {
|
|
260
|
+
case ComponentType.ActionRow:
|
|
261
|
+
return component.components;
|
|
262
|
+
case ComponentType.Section:
|
|
263
|
+
return [...component.components, component.accessory];
|
|
264
|
+
case ComponentType.Container:
|
|
265
|
+
return component.components.flatMap(extractInteractiveComponents);
|
|
266
|
+
default:
|
|
267
|
+
return [component];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Finds a component by customId in nested components
|
|
273
|
+
*
|
|
274
|
+
* @param {Array<Component|APIMessageComponent>} components The components to search in
|
|
275
|
+
* @param {string} customId The customId to search for
|
|
276
|
+
* @returns {Component|APIMessageComponent}
|
|
277
|
+
* @ignore
|
|
278
|
+
*/
|
|
279
|
+
export function findComponentByCustomId(components, customId) {
|
|
280
|
+
return (
|
|
281
|
+
components
|
|
282
|
+
.flatMap(extractInteractiveComponents)
|
|
283
|
+
.find(component => (component.customId ?? component.custom_id) === customId) ?? null
|
|
284
|
+
);
|
|
285
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { ChannelType, MessageType, ComponentType, ImageFormat, StickerFormatType } from 'discord-api-types/v10';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Max bulk deletable message age
|
|
5
|
+
*
|
|
6
|
+
* @typedef {number} MaxBulkDeletableMessageAge
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The name of an item to be swept in Sweepers
|
|
12
|
+
* - `autoModerationRules`
|
|
13
|
+
* - `applicationCommands` - both global and guild commands
|
|
14
|
+
* - `bans`
|
|
15
|
+
* - `emojis`
|
|
16
|
+
* - `entitlements`
|
|
17
|
+
* - `invites` - accepts the `lifetime` property, using it will sweep based on expires timestamp
|
|
18
|
+
* - `guildMembers`
|
|
19
|
+
* - `messages` - accepts the `lifetime` property, using it will sweep based on edited or created timestamp
|
|
20
|
+
* - `presences`
|
|
21
|
+
* - `reactions`
|
|
22
|
+
* - `stageInstances`
|
|
23
|
+
* - `stickers`
|
|
24
|
+
* - `threadMembers`
|
|
25
|
+
* - `threads` - accepts the `lifetime` property, using it will sweep archived threads based on archived timestamp
|
|
26
|
+
* - `users`
|
|
27
|
+
* - `voiceStates`
|
|
28
|
+
*
|
|
29
|
+
* @typedef {string} SweeperKey
|
|
30
|
+
*/
|
|
31
|
+
exports.SweeperKeys = [
|
|
32
|
+
'autoModerationRules',
|
|
33
|
+
'applicationCommands',
|
|
34
|
+
'bans',
|
|
35
|
+
'emojis',
|
|
36
|
+
'entitlements',
|
|
37
|
+
'invites',
|
|
38
|
+
'guildMembers',
|
|
39
|
+
'messages',
|
|
40
|
+
'presences',
|
|
41
|
+
'reactions',
|
|
42
|
+
'stageInstances',
|
|
43
|
+
'stickers',
|
|
44
|
+
'threadMembers',
|
|
45
|
+
'threads',
|
|
46
|
+
'users',
|
|
47
|
+
'voiceStates',
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The types of messages that are not `System`. The available types are:
|
|
52
|
+
* - {@link MessageType.Default}
|
|
53
|
+
* - {@link MessageType.Reply}
|
|
54
|
+
* - {@link MessageType.ChatInputCommand}
|
|
55
|
+
* - {@link MessageType.ContextMenuCommand}
|
|
56
|
+
*
|
|
57
|
+
* @typedef {MessageType[]} NonSystemMessageTypes
|
|
58
|
+
*/
|
|
59
|
+
exports.NonSystemMessageTypes = [
|
|
60
|
+
MessageType.Default,
|
|
61
|
+
MessageType.Reply,
|
|
62
|
+
MessageType.ChatInputCommand,
|
|
63
|
+
MessageType.ContextMenuCommand,
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The guild channels that are text-based.
|
|
68
|
+
* - TextChannel
|
|
69
|
+
* - AnnouncementChannel
|
|
70
|
+
* - ThreadChannel
|
|
71
|
+
* - VoiceChannel
|
|
72
|
+
* - StageChannel
|
|
73
|
+
*
|
|
74
|
+
* @typedef {TextChannel|AnnouncementChannel|ThreadChannel|VoiceChannel|StageChannel} GuildTextBasedChannel
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The types of guild channels that are text-based. The available types are:
|
|
79
|
+
* - {@link ChannelType.GuildText}
|
|
80
|
+
* - {@link ChannelType.GuildAnnouncement}
|
|
81
|
+
* - {@link ChannelType.AnnouncementThread}
|
|
82
|
+
* - {@link ChannelType.PublicThread}
|
|
83
|
+
* - {@link ChannelType.PrivateThread}
|
|
84
|
+
* - {@link ChannelType.GuildVoice}
|
|
85
|
+
* - {@link ChannelType.GuildStageVoice}
|
|
86
|
+
*
|
|
87
|
+
* @typedef {ChannelType[]} GuildTextBasedChannelTypes
|
|
88
|
+
*/
|
|
89
|
+
exports.GuildTextBasedChannelTypes = [
|
|
90
|
+
ChannelType.GuildText,
|
|
91
|
+
ChannelType.GuildAnnouncement,
|
|
92
|
+
ChannelType.AnnouncementThread,
|
|
93
|
+
ChannelType.PublicThread,
|
|
94
|
+
ChannelType.PrivateThread,
|
|
95
|
+
ChannelType.GuildVoice,
|
|
96
|
+
ChannelType.GuildStageVoice,
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The channels that are text-based.
|
|
101
|
+
* - {@link DMChannel}
|
|
102
|
+
* - {@link GuildTextBasedChannel}
|
|
103
|
+
*
|
|
104
|
+
* @typedef {DMChannel|GuildTextBasedChannel} TextBasedChannels
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Data that resolves to give a text-based channel. This can be:
|
|
109
|
+
* - A {@link TextBasedChannel}
|
|
110
|
+
* - A {@link Snowflake}
|
|
111
|
+
*
|
|
112
|
+
* @typedef {TextBasedChannels|Snowflake} TextBasedChannelsResolvable
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The types of channels that are text-based. The available types are:
|
|
117
|
+
* - {@link ChannelType.DM}
|
|
118
|
+
* - {@link ChannelType.GuildText}
|
|
119
|
+
* - {@link ChannelType.GuildAnnouncement}
|
|
120
|
+
* - {@link ChannelType.AnnouncementThread}
|
|
121
|
+
* - {@link ChannelType.PublicThread}
|
|
122
|
+
* - {@link ChannelType.PrivateThread}
|
|
123
|
+
* - {@link ChannelType.GuildVoice}
|
|
124
|
+
* - {@link ChannelType.GuildStageVoice}
|
|
125
|
+
* - {@link ChannelType.GroupDM}
|
|
126
|
+
*
|
|
127
|
+
* @typedef {ChannelType[]} TextBasedChannelTypes
|
|
128
|
+
*/
|
|
129
|
+
exports.TextBasedChannelTypes = [...exports.GuildTextBasedChannelTypes, ChannelType.DM, ChannelType.GroupDM];
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The types of channels that are text-based and can have messages sent into. The available types are:
|
|
133
|
+
* - {@link ChannelType.DM}
|
|
134
|
+
* - {@link ChannelType.GuildText}
|
|
135
|
+
* - {@link ChannelType.GuildAnnouncement}
|
|
136
|
+
* - {@link ChannelType.AnnouncementThread}
|
|
137
|
+
* - {@link ChannelType.PublicThread}
|
|
138
|
+
* - {@link ChannelType.PrivateThread}
|
|
139
|
+
* - {@link ChannelType.GuildVoice}
|
|
140
|
+
* - {@link ChannelType.GuildStageVoice}
|
|
141
|
+
*
|
|
142
|
+
* @typedef {ChannelType[]} SendableChannels
|
|
143
|
+
*/
|
|
144
|
+
exports.SendableChannels = [...exports.GuildTextBasedChannelTypes, ChannelType.DM];
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The types of channels that are threads. The available types are:
|
|
148
|
+
* - {@link ChannelType.AnnouncementThread}
|
|
149
|
+
* - {@link ChannelType.PublicThread}
|
|
150
|
+
* - {@link ChannelType.PrivateThread}
|
|
151
|
+
*
|
|
152
|
+
* @typedef {ChannelType[]} ThreadChannelTypes
|
|
153
|
+
*/
|
|
154
|
+
exports.ThreadChannelTypes = [ChannelType.AnnouncementThread, ChannelType.PublicThread, ChannelType.PrivateThread];
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The types of channels that are voice-based. The available types are:
|
|
158
|
+
* - {@link ChannelType.GuildVoice}
|
|
159
|
+
* - {@link ChannelType.GuildStageVoice}
|
|
160
|
+
*
|
|
161
|
+
* @typedef {ChannelType[]} VoiceBasedChannelTypes
|
|
162
|
+
*/
|
|
163
|
+
exports.VoiceBasedChannelTypes = [ChannelType.GuildVoice, ChannelType.GuildStageVoice];
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The types of select menus. The available types are:
|
|
167
|
+
* - {@link ComponentType.StringSelect}
|
|
168
|
+
* - {@link ComponentType.UserSelect}
|
|
169
|
+
* - {@link ComponentType.RoleSelect}
|
|
170
|
+
* - {@link ComponentType.MentionableSelect}
|
|
171
|
+
* - {@link ComponentType.ChannelSelect}
|
|
172
|
+
*
|
|
173
|
+
* @typedef {ComponentType[]} SelectMenuTypes
|
|
174
|
+
*/
|
|
175
|
+
exports.SelectMenuTypes = [
|
|
176
|
+
ComponentType.StringSelect,
|
|
177
|
+
ComponentType.UserSelect,
|
|
178
|
+
ComponentType.RoleSelect,
|
|
179
|
+
ComponentType.MentionableSelect,
|
|
180
|
+
ComponentType.ChannelSelect,
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The types of messages that cannot be deleted. The available types are:
|
|
185
|
+
* - {@link MessageType.RecipientAdd}
|
|
186
|
+
* - {@link MessageType.RecipientRemove}
|
|
187
|
+
* - {@link MessageType.Call}
|
|
188
|
+
* - {@link MessageType.ChannelNameChange}
|
|
189
|
+
* - {@link MessageType.ChannelIconChange}
|
|
190
|
+
* - {@link MessageType.ThreadStarterMessage}
|
|
191
|
+
*
|
|
192
|
+
* @typedef {MessageType[]} UndeletableMessageTypes
|
|
193
|
+
*/
|
|
194
|
+
exports.UndeletableMessageTypes = [
|
|
195
|
+
MessageType.RecipientAdd,
|
|
196
|
+
MessageType.RecipientRemove,
|
|
197
|
+
MessageType.Call,
|
|
198
|
+
MessageType.ChannelNameChange,
|
|
199
|
+
MessageType.ChannelIconChange,
|
|
200
|
+
MessageType.ThreadStarterMessage,
|
|
201
|
+
];
|
|
202
|
+
|
|
203
|
+
/* eslint-disable jsdoc/valid-types */
|
|
204
|
+
/**
|
|
205
|
+
* A mapping between sticker formats and their respective image formats.
|
|
206
|
+
* - {@link StickerFormatType.PNG} -> {@link ImageFormat.PNG}
|
|
207
|
+
* - {@link StickerFormatType.APNG} -> {@link ImageFormat.PNG}
|
|
208
|
+
* - {@link StickerFormatType.Lottie} -> {@link ImageFormat.Lottie}
|
|
209
|
+
* - {@link StickerFormatType.GIF} -> {@link ImageFormat.GIF}
|
|
210
|
+
*
|
|
211
|
+
* @typedef {Object} StickerFormatExtensionMap
|
|
212
|
+
* @property {"png"} 1 PNG
|
|
213
|
+
* @property {"png"} 2 APNG
|
|
214
|
+
* @property {"json"} 3 Lottie
|
|
215
|
+
* @property {"gif"} 4 GIF
|
|
216
|
+
*/
|
|
217
|
+
exports.StickerFormatExtensionMap = {
|
|
218
|
+
[StickerFormatType.PNG]: ImageFormat.PNG,
|
|
219
|
+
[StickerFormatType.APNG]: ImageFormat.PNG,
|
|
220
|
+
[StickerFormatType.Lottie]: ImageFormat.Lottie,
|
|
221
|
+
[StickerFormatType.GIF]: ImageFormat.GIF,
|
|
222
|
+
};
|
|
223
|
+
/* eslint-enable jsdoc/valid-types */
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Holographic color values for role styling.
|
|
227
|
+
* When using `tertiaryColor`, the API enforces these specific values for holographic effect.
|
|
228
|
+
*
|
|
229
|
+
* @typedef {Object} HolographicStyle
|
|
230
|
+
* @property {number} Primary 11127295 (0xA9FFFF)
|
|
231
|
+
* @property {number} Secondary 16759788 (0xFFCCCC)
|
|
232
|
+
* @property {number} Tertiary 16761760 (0xFFE0A0)
|
|
233
|
+
*/
|
|
234
|
+
exports.HolographicStyle = {
|
|
235
|
+
Primary: 11_127_295,
|
|
236
|
+
Secondary: 16_759_788,
|
|
237
|
+
Tertiary: 16_761_760,
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @typedef {Object} Constants Constants that can be used in an enum or object-like way.
|
|
242
|
+
* @property {number} MaxBulkDeletableMessageAge Max bulk deletable message age
|
|
243
|
+
* @property {SweeperKey[]} SweeperKeys The possible names of items that can be swept in sweepers
|
|
244
|
+
* @property {NonSystemMessageTypes} NonSystemMessageTypes The types of messages that are not deemed a system type
|
|
245
|
+
* @property {TextBasedChannelTypes} TextBasedChannelTypes The types of channels that are text-based
|
|
246
|
+
* @property {ThreadChannelTypes} ThreadChannelTypes The types of channels that are threads
|
|
247
|
+
* @property {VoiceBasedChannelTypes} VoiceBasedChannelTypes The types of channels that are voice-based
|
|
248
|
+
* @property {SelectMenuTypes} SelectMenuTypes The types of components that are select menus.
|
|
249
|
+
* @property {Object} StickerFormatExtensionMap A mapping between sticker formats and their respective image formats.
|
|
250
|
+
* @property {HolographicStyle} HolographicStyle Holographic color values for role styling.
|
|
251
|
+
*/
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { lazy } from '@ovencord/util';
|
|
6
|
+
import { DiscordjsError, DiscordjsTypeError, ErrorCodes } from '../errors/index.js';
|
|
7
|
+
import { BaseInvite } from '../structures/BaseInvite.js';
|
|
8
|
+
|
|
9
|
+
// Fixes circular dependencies.
|
|
10
|
+
const getGuildTemplate = lazy(() => require('../structures/GuildTemplate.js').GuildTemplate);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Data that can be resolved to give an invite code. This can be:
|
|
14
|
+
* - An invite code
|
|
15
|
+
* - An invite URL
|
|
16
|
+
*
|
|
17
|
+
* @typedef {string} InviteResolvable
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Data that can be resolved to give a template code. This can be:
|
|
22
|
+
* - A template code
|
|
23
|
+
* - A template URL
|
|
24
|
+
*
|
|
25
|
+
* @typedef {string} GuildTemplateResolvable
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the string to a code based on the passed regex.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} data The string to resolve
|
|
32
|
+
* @param {RegExp} regex The RegExp used to extract the code
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
export function resolveCode(data, regex) {
|
|
36
|
+
return regex.exec(data)?.[1] ?? data;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Resolves InviteResolvable to an invite code.
|
|
41
|
+
*
|
|
42
|
+
* @param {InviteResolvable} data The invite resolvable to resolve
|
|
43
|
+
* @returns {string}
|
|
44
|
+
*/
|
|
45
|
+
export function resolveInviteCode(data) {
|
|
46
|
+
return resolveCode(data, BaseInvite.InvitesPattern);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Resolves GuildTemplateResolvable to a template code.
|
|
51
|
+
*
|
|
52
|
+
* @param {GuildTemplateResolvable} data The template resolvable to resolve
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
export function resolveGuildTemplateCode(data) {
|
|
56
|
+
return resolveCode(data, getGuildTemplate().GuildTemplatesPattern);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Data that can be resolved to give a Buffer. This can be:
|
|
61
|
+
* - A Buffer
|
|
62
|
+
* - The path to a local file
|
|
63
|
+
* - A URL <warn>When provided a URL, discord.js will fetch the URL internally in order to create a Buffer.
|
|
64
|
+
* This can pose a security risk when the URL has not been sanitized</warn>
|
|
65
|
+
*
|
|
66
|
+
* @typedef {string|Buffer} BufferResolvable
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @external Stream
|
|
71
|
+
* @see {@link https://nodejs.org/api/stream.html}
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {Object} ResolvedFile
|
|
76
|
+
* @property {Buffer} data Buffer containing the file data
|
|
77
|
+
* @property {string} [contentType] Content-Type of the file
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Resolves a BufferResolvable to a Buffer.
|
|
83
|
+
*
|
|
84
|
+
* @param {BufferResolvable|Stream} resource The buffer or stream resolvable to resolve
|
|
85
|
+
* @returns {Promise<ResolvedFile>}
|
|
86
|
+
*/
|
|
87
|
+
export async function resolveFile(resource) {
|
|
88
|
+
if (Buffer.isBuffer(resource)) return { data: resource };
|
|
89
|
+
|
|
90
|
+
if (typeof resource[Symbol.asyncIterator] === 'function') {
|
|
91
|
+
const buffers = [];
|
|
92
|
+
for await (const data of resource) buffers.push(Buffer.from(data));
|
|
93
|
+
return { data: Buffer.concat(buffers) };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (typeof resource === 'string') {
|
|
97
|
+
if (/^https?:\/\//.test(resource)) {
|
|
98
|
+
const res = await fetch(resource);
|
|
99
|
+
return { data: Buffer.from(await res.arrayBuffer()), contentType: res.headers.get('content-type') };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const file = path.resolve(resource);
|
|
103
|
+
|
|
104
|
+
const stats = await fs.stat(file);
|
|
105
|
+
if (!stats.isFile()) throw new DiscordjsError(ErrorCodes.FileNotFound, file);
|
|
106
|
+
return { data: await fs.readFile(file) };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
throw new DiscordjsTypeError(ErrorCodes.ReqResourceType);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Data that resolves to give a Base64 string, typically for image uploading. This can be:
|
|
114
|
+
* - A Buffer
|
|
115
|
+
* - A base64 string
|
|
116
|
+
*
|
|
117
|
+
* @typedef {Buffer|string} Base64Resolvable
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Resolves a Base64Resolvable to a Base 64 string.
|
|
122
|
+
*
|
|
123
|
+
* @param {Base64Resolvable} data The base 64 resolvable you want to resolve
|
|
124
|
+
* @param {string} [contentType='image/jpg'] The content type of the data
|
|
125
|
+
* @returns {string}
|
|
126
|
+
*/
|
|
127
|
+
export function resolveBase64(data, contentType = 'image/jpg') {
|
|
128
|
+
if (Buffer.isBuffer(data)) return `data:${contentType};base64,${data.toString('base64')}`;
|
|
129
|
+
return data;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Resolves a Base64Resolvable, a string, or a BufferResolvable to a Base 64 image.
|
|
134
|
+
*
|
|
135
|
+
* @param {BufferResolvable|Base64Resolvable} image The image to be resolved
|
|
136
|
+
* @returns {Promise<?string>}
|
|
137
|
+
*/
|
|
138
|
+
export async function resolveImage(image) {
|
|
139
|
+
if (!image) return null;
|
|
140
|
+
if (typeof image === 'string' && image.startsWith('data:')) {
|
|
141
|
+
return image;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const file = await resolveFile(image);
|
|
145
|
+
return resolveBase64(file.data);
|
|
146
|
+
}
|