lolka.js 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/package.json +21 -52
- package/src/client/BaseClient.js +120 -0
- package/src/client/Client.js +147 -446
- package/src/client/WebhookClient.js +103 -0
- package/src/client/actions/Action.js +3 -4
- package/src/client/actions/ActionsManager.js +65 -55
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
- package/src/client/actions/AutoModerationActionExecution.js +26 -0
- package/src/client/actions/AutoModerationRuleCreate.js +27 -0
- package/src/client/actions/AutoModerationRuleDelete.js +31 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +29 -0
- package/src/client/actions/ChannelCreate.js +3 -5
- package/src/client/actions/ChannelDelete.js +3 -4
- package/src/client/actions/ChannelUpdate.js +3 -3
- package/src/client/actions/EntitlementCreate.js +23 -0
- package/src/client/actions/EntitlementDelete.js +27 -0
- package/src/client/actions/EntitlementUpdate.js +25 -0
- package/src/client/actions/GuildAuditLogEntryCreate.js +29 -0
- package/src/client/actions/GuildBanAdd.js +20 -0
- package/src/client/actions/GuildBanRemove.js +25 -0
- package/src/client/actions/GuildChannelsPositionUpdate.js +3 -3
- package/src/client/actions/GuildDelete.js +44 -0
- package/src/client/actions/GuildEmojiCreate.js +3 -4
- package/src/client/actions/GuildEmojiDelete.js +3 -4
- package/src/client/actions/GuildEmojiUpdate.js +3 -4
- package/src/client/actions/GuildEmojisUpdate.js +2 -2
- package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
- package/src/client/actions/GuildMemberRemove.js +6 -8
- package/src/client/actions/GuildMemberUpdate.js +6 -7
- package/src/client/actions/GuildRoleCreate.js +4 -6
- package/src/client/actions/GuildRoleDelete.js +3 -4
- package/src/client/actions/GuildRoleUpdate.js +39 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +3 -3
- package/src/client/actions/GuildScheduledEventCreate.js +27 -0
- package/src/client/actions/GuildScheduledEventDelete.js +3 -4
- package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
- package/src/client/actions/GuildScheduledEventUserAdd.js +3 -4
- package/src/client/actions/GuildScheduledEventUserRemove.js +3 -4
- package/src/client/actions/GuildSoundboardSoundDelete.js +3 -4
- package/src/client/actions/GuildStickerCreate.js +3 -4
- package/src/client/actions/GuildStickerDelete.js +3 -4
- package/src/client/actions/GuildStickerUpdate.js +3 -4
- package/src/client/actions/GuildStickersUpdate.js +2 -2
- package/src/client/actions/GuildUpdate.js +3 -4
- package/src/client/actions/InteractionCreate.js +15 -18
- package/src/client/actions/InviteCreate.js +27 -0
- package/src/client/actions/InviteDelete.js +29 -0
- package/src/client/actions/MessageCreate.js +3 -4
- package/src/client/actions/MessageDelete.js +3 -4
- package/src/client/actions/MessageDeleteBulk.js +3 -5
- package/src/client/actions/MessagePollVoteAdd.js +3 -4
- package/src/client/actions/MessagePollVoteRemove.js +3 -4
- package/src/client/actions/MessageReactionAdd.js +5 -7
- package/src/client/actions/MessageReactionRemove.js +4 -5
- package/src/client/actions/MessageReactionRemoveAll.js +4 -5
- package/src/client/actions/MessageReactionRemoveEmoji.js +4 -5
- package/src/client/actions/MessageUpdate.js +2 -2
- package/src/client/actions/PresenceUpdate.js +45 -0
- package/src/client/actions/StageInstanceCreate.js +3 -4
- package/src/client/actions/StageInstanceDelete.js +3 -4
- package/src/client/actions/StageInstanceUpdate.js +3 -4
- package/src/client/actions/ThreadCreate.js +3 -5
- package/src/client/actions/ThreadDelete.js +26 -0
- package/src/client/actions/ThreadListSync.js +60 -0
- package/src/client/actions/ThreadMemberUpdate.js +30 -0
- package/src/client/actions/ThreadMembersUpdate.js +3 -5
- package/src/client/actions/TypingStart.js +5 -6
- package/src/client/actions/UserUpdate.js +3 -4
- package/src/client/actions/VoiceStateUpdate.js +43 -0
- package/src/client/actions/WebhooksUpdate.js +37 -0
- package/src/client/voice/ClientVoiceManager.js +6 -10
- package/src/client/websocket/WebSocketManager.js +407 -0
- package/src/client/websocket/WebSocketShard.js +234 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +2 -27
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +2 -15
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +2 -16
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +2 -19
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +2 -18
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +1 -2
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -2
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.js +2 -12
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.js +2 -16
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.js +2 -14
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +2 -17
- package/src/client/websocket/handlers/GUILD_BAN_ADD.js +2 -13
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +2 -18
- package/src/client/websocket/handlers/GUILD_CREATE.js +5 -7
- package/src/client/websocket/handlers/GUILD_DELETE.js +2 -34
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +2 -13
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +1 -3
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +11 -9
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +2 -2
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +2 -2
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +2 -19
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +2 -15
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +2 -17
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +1 -2
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +1 -2
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +1 -2
- package/src/client/websocket/handlers/INVITE_CREATE.js +2 -18
- package/src/client/websocket/handlers/INVITE_DELETE.js +2 -21
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -2
- package/src/client/websocket/handlers/PRESENCE_UPDATE.js +2 -40
- package/src/client/websocket/handlers/RATE_LIMITED.js +2 -1
- package/src/client/websocket/handlers/READY.js +5 -8
- package/src/client/websocket/handlers/RESUMED.js +14 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.js +1 -2
- package/src/client/websocket/handlers/THREAD_DELETE.js +2 -15
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +2 -49
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +2 -23
- package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -2
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +2 -3
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +3 -30
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +2 -35
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +2 -14
- package/src/client/websocket/handlers/index.js +75 -74
- package/src/errors/DJSError.js +7 -7
- package/src/errors/ErrorCodes.js +134 -58
- package/src/errors/Messages.js +143 -115
- package/src/errors/index.js +3 -5
- package/src/index.js +226 -234
- package/src/managers/ApplicationCommandManager.js +24 -60
- package/src/managers/ApplicationCommandPermissionsManager.js +33 -57
- package/src/managers/ApplicationEmojiManager.js +8 -18
- package/src/managers/AutoModerationRuleManager.js +6 -24
- package/src/managers/BaseGuildEmojiManager.js +85 -0
- package/src/managers/BaseManager.js +1 -3
- package/src/managers/CachedManager.js +8 -12
- package/src/managers/CategoryChannelChildManager.js +4 -10
- package/src/managers/ChannelManager.js +8 -70
- package/src/managers/DMMessageManager.js +2 -4
- package/src/managers/DataManager.js +5 -10
- package/src/managers/EntitlementManager.js +8 -19
- package/src/managers/GuildApplicationCommandManager.js +3 -6
- package/src/managers/GuildBanManager.js +52 -27
- package/src/managers/GuildChannelManager.js +54 -91
- package/src/managers/GuildEmojiManager.js +18 -108
- package/src/managers/GuildEmojiRoleManager.js +14 -24
- package/src/managers/GuildForumThreadManager.js +5 -10
- package/src/managers/GuildInviteManager.js +27 -51
- package/src/managers/GuildManager.js +185 -45
- package/src/managers/GuildMemberManager.js +105 -89
- package/src/managers/GuildMemberRoleManager.js +14 -29
- package/src/managers/GuildMessageManager.js +2 -20
- package/src/managers/GuildScheduledEventManager.js +13 -31
- package/src/managers/GuildSoundboardSoundManager.js +5 -17
- package/src/managers/GuildStickerManager.js +21 -34
- package/src/managers/GuildTextThreadManager.js +5 -9
- package/src/managers/MessageManager.js +77 -64
- package/src/managers/PartialGroupDMMessageManager.js +2 -4
- package/src/managers/PermissionOverwriteManager.js +15 -26
- package/src/managers/PollAnswerVoterManager.js +2 -14
- package/src/managers/PresenceManager.js +6 -11
- package/src/managers/ReactionManager.js +6 -13
- package/src/managers/ReactionUserManager.js +4 -11
- package/src/managers/RoleManager.js +74 -76
- package/src/managers/StageInstanceManager.js +8 -18
- package/src/managers/SubscriptionManager.js +4 -9
- package/src/managers/ThreadManager.js +13 -33
- package/src/managers/ThreadMemberManager.js +34 -27
- package/src/managers/UserManager.js +34 -32
- package/src/managers/VoiceStateManager.js +4 -9
- package/src/sharding/Shard.js +40 -64
- package/src/sharding/ShardClientUtil.js +60 -60
- package/src/sharding/ShardingManager.js +30 -89
- package/src/structures/ActionRow.js +18 -6
- package/src/structures/ActionRowBuilder.js +35 -0
- package/src/structures/AnonymousGuild.js +10 -14
- package/src/structures/ApplicationCommand.js +49 -67
- package/src/structures/ApplicationEmoji.js +5 -22
- package/src/structures/ApplicationRoleConnectionMetadata.js +0 -6
- package/src/structures/Attachment.js +7 -25
- package/src/structures/AttachmentBuilder.js +111 -0
- package/src/structures/AutoModerationActionExecution.js +2 -17
- package/src/structures/AutoModerationRule.js +17 -46
- package/src/structures/AutocompleteInteraction.js +4 -14
- package/src/structures/Base.js +2 -4
- package/src/structures/BaseChannel.js +4 -21
- package/src/structures/BaseGuild.js +7 -19
- package/src/structures/BaseGuildEmoji.js +13 -13
- package/src/structures/BaseGuildTextChannel.js +16 -45
- package/src/structures/BaseGuildVoiceChannel.js +12 -43
- package/src/structures/BaseInteraction.js +25 -54
- package/src/structures/BaseSelectMenuComponent.js +2 -8
- package/src/structures/ButtonBuilder.js +44 -0
- package/src/structures/ButtonComponent.js +2 -9
- package/src/structures/ButtonInteraction.js +2 -3
- package/src/structures/CategoryChannel.js +3 -8
- package/src/structures/ChannelSelectMenuBuilder.js +31 -0
- package/src/structures/ChannelSelectMenuComponent.js +2 -4
- package/src/structures/ChannelSelectMenuInteraction.js +2 -5
- package/src/structures/ChatInputCommandInteraction.js +4 -7
- package/src/structures/ClientApplication.js +12 -60
- package/src/structures/ClientPresence.js +10 -15
- package/src/structures/ClientUser.js +19 -36
- package/src/structures/CommandInteraction.js +7 -27
- package/src/structures/CommandInteractionOptionResolver.js +8 -36
- package/src/structures/Component.js +1 -7
- package/src/structures/ContainerComponent.js +3 -9
- package/src/structures/ContextMenuCommandInteraction.js +5 -9
- package/src/structures/DMChannel.js +15 -34
- package/src/structures/DirectoryChannel.js +2 -6
- package/src/structures/Embed.js +2 -19
- package/src/structures/EmbedBuilder.js +50 -0
- package/src/structures/Emoji.js +19 -19
- package/src/structures/Entitlement.js +2 -22
- package/src/structures/FileComponent.js +3 -7
- package/src/structures/ForumChannel.js +3 -6
- package/src/structures/Guild.js +131 -187
- package/src/structures/GuildAuditLogs.js +6 -12
- package/src/structures/GuildAuditLogsEntry.js +63 -88
- package/src/structures/GuildBan.js +3 -9
- package/src/structures/GuildChannel.js +33 -68
- package/src/structures/GuildEmoji.js +7 -19
- package/src/structures/GuildMember.js +58 -107
- package/src/structures/GuildOnboarding.js +2 -9
- package/src/structures/GuildOnboardingPrompt.js +2 -12
- package/src/structures/GuildOnboardingPromptOption.js +2 -12
- package/src/structures/GuildPreview.js +21 -30
- package/src/structures/GuildPreviewEmoji.js +2 -5
- package/src/structures/GuildScheduledEvent.js +19 -59
- package/src/structures/GuildTemplate.js +45 -24
- package/src/structures/Integration.js +7 -30
- package/src/structures/IntegrationApplication.js +12 -9
- package/src/structures/InteractionCallback.js +1 -10
- package/src/structures/InteractionCallbackResource.js +2 -7
- package/src/structures/InteractionCallbackResponse.js +3 -6
- package/src/structures/InteractionCollector.js +36 -23
- package/src/structures/InteractionResponse.js +102 -0
- package/src/structures/InteractionWebhook.js +6 -14
- package/src/structures/Invite.js +341 -0
- package/src/structures/InviteGuild.js +4 -6
- package/src/structures/InviteStageInstance.js +87 -0
- package/src/structures/LabelComponent.js +3 -3
- package/src/structures/MediaChannel.js +2 -3
- package/src/structures/MediaGalleryComponent.js +3 -6
- package/src/structures/MediaGalleryItem.js +2 -7
- package/src/structures/MentionableSelectMenuBuilder.js +32 -0
- package/src/structures/MentionableSelectMenuComponent.js +2 -3
- package/src/structures/MentionableSelectMenuInteraction.js +3 -8
- package/src/structures/Message.js +100 -169
- package/src/structures/MessageCollector.js +5 -16
- package/src/structures/MessageComponentInteraction.js +14 -34
- package/src/structures/MessageContextMenuCommandInteraction.js +2 -4
- package/src/structures/MessageMentions.js +4 -30
- package/src/structures/MessagePayload.js +90 -92
- package/src/structures/MessageReaction.js +17 -31
- package/src/structures/ModalBuilder.js +36 -0
- package/src/structures/{ModalComponentResolver.js → ModalSubmitFields.js} +31 -37
- package/src/structures/ModalSubmitInteraction.js +55 -54
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +3 -6
- package/src/structures/PartialGroupDMChannel.js +11 -23
- package/src/structures/PermissionOverwrites.js +25 -47
- package/src/structures/Poll.js +4 -19
- package/src/structures/PollAnswer.js +29 -13
- package/src/structures/Presence.js +13 -57
- package/src/structures/PrimaryEntryPointCommandInteraction.js +2 -3
- package/src/structures/ReactionCollector.js +4 -21
- package/src/structures/ReactionEmoji.js +3 -5
- package/src/structures/Role.js +48 -65
- package/src/structures/RoleSelectMenuBuilder.js +31 -0
- package/src/structures/RoleSelectMenuComponent.js +2 -3
- package/src/structures/RoleSelectMenuInteraction.js +2 -5
- package/src/structures/SKU.js +2 -9
- package/src/structures/SectionComponent.js +3 -7
- package/src/structures/SelectMenuBuilder.js +26 -0
- package/src/structures/SelectMenuComponent.js +26 -0
- package/src/structures/SelectMenuInteraction.js +26 -0
- package/src/structures/SelectMenuOptionBuilder.js +26 -0
- package/src/structures/SeparatorComponent.js +2 -5
- package/src/structures/SoundboardSound.js +2 -18
- package/src/structures/StageChannel.js +4 -13
- package/src/structures/StageInstance.js +16 -19
- package/src/structures/Sticker.js +4 -28
- package/src/structures/StickerPack.js +4 -16
- package/src/structures/StringSelectMenuBuilder.js +79 -0
- package/src/structures/StringSelectMenuComponent.js +2 -4
- package/src/structures/StringSelectMenuInteraction.js +2 -4
- package/src/structures/StringSelectMenuOptionBuilder.js +49 -0
- package/src/structures/Subscription.js +1 -15
- package/src/structures/Team.js +7 -16
- package/src/structures/TeamMember.js +15 -9
- package/src/structures/TextChannel.js +3 -6
- package/src/structures/TextDisplayComponent.js +2 -4
- package/src/structures/TextInputBuilder.js +31 -0
- package/src/structures/TextInputComponent.js +2 -5
- package/src/structures/ThreadChannel.js +35 -85
- package/src/structures/ThreadMember.js +12 -17
- package/src/structures/ThreadOnlyChannel.js +15 -36
- package/src/structures/ThumbnailComponent.js +3 -8
- package/src/structures/Typing.js +2 -10
- package/src/structures/UnfurledMediaItem.js +2 -5
- package/src/structures/User.js +68 -60
- package/src/structures/UserContextMenuCommandInteraction.js +2 -5
- package/src/structures/UserSelectMenuBuilder.js +31 -0
- package/src/structures/UserSelectMenuComponent.js +2 -3
- package/src/structures/UserSelectMenuInteraction.js +3 -7
- package/src/structures/VoiceChannel.js +4 -11
- package/src/structures/VoiceChannelEffect.js +2 -12
- package/src/structures/VoiceRegion.js +2 -7
- package/src/structures/VoiceState.js +10 -36
- package/src/structures/Webhook.js +37 -65
- package/src/structures/WelcomeChannel.js +5 -12
- package/src/structures/WelcomeScreen.js +3 -8
- package/src/structures/Widget.js +3 -13
- package/src/structures/WidgetMember.js +2 -17
- package/src/structures/interfaces/Application.js +10 -19
- package/src/structures/interfaces/Collector.js +12 -45
- package/src/structures/interfaces/InteractionResponses.js +152 -43
- package/src/structures/interfaces/TextBasedChannel.js +99 -83
- package/src/util/APITypes.js +16 -30
- package/src/util/ActivityFlagsBitField.js +2 -5
- package/src/util/ApplicationFlagsBitField.js +6 -11
- package/src/util/AttachmentFlagsBitField.js +2 -5
- package/src/util/BitField.js +8 -27
- package/src/util/ChannelFlagsBitField.js +6 -11
- package/src/util/Channels.js +61 -73
- package/src/util/Colors.js +43 -43
- package/src/util/Components.js +82 -61
- package/src/util/Constants.js +124 -94
- package/src/util/DataResolver.js +17 -36
- package/src/util/Enums.js +1 -2
- package/src/util/Events.js +14 -3
- package/src/util/Formatters.js +413 -0
- package/src/util/GuildMemberFlagsBitField.js +5 -9
- package/src/util/IntentsBitField.js +6 -10
- package/src/util/InviteFlagsBitField.js +1 -2
- package/src/util/LimitedCollection.js +6 -13
- package/src/util/LolkaSnowflake.js +14 -1
- package/src/util/MessageFlagsBitField.js +6 -11
- package/src/util/Options.js +57 -35
- package/src/util/Partials.js +4 -5
- package/src/util/PermissionsBitField.js +8 -21
- package/src/util/RoleFlagsBitField.js +2 -5
- package/src/util/SKUFlagsBitField.js +1 -4
- package/src/util/ShardEvents.js +3 -1
- package/src/util/Status.js +21 -5
- package/src/util/Sweepers.js +13 -59
- package/src/util/SystemChannelFlagsBitField.js +6 -11
- package/src/util/ThreadMemberFlagsBitField.js +2 -6
- package/src/util/Transformers.js +18 -17
- package/src/util/UserFlagsBitField.js +2 -6
- package/src/util/Util.js +97 -148
- package/src/util/WebSocketShardEvents.js +25 -0
- package/typings/index.d.mts +2394 -1771
- package/typings/index.d.ts +2394 -1771
- package/typings/rawDataTypes.d.ts +211 -0
- package/src/structures/ActivityInstance.js +0 -52
- package/src/structures/ActivityLocation.js +0 -65
- package/src/structures/AnnouncementChannel.js +0 -29
- package/src/structures/AuthorizingIntegrationOwners.js +0 -64
- package/src/structures/BaseInvite.js +0 -187
- package/src/structures/GroupDMInvite.js +0 -37
- package/src/structures/GuildInvite.js +0 -223
- package/src/util/Invites.js +0 -31
|
@@ -8,31 +8,30 @@ const {
|
|
|
8
8
|
ChannelType,
|
|
9
9
|
MessageType,
|
|
10
10
|
MessageFlags,
|
|
11
|
-
MessageReferenceType,
|
|
12
11
|
PermissionFlagsBits,
|
|
12
|
+
MessageReferenceType,
|
|
13
13
|
} = require('discord-api-types/v10');
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const { cleanContent, resolvePartialEmoji, transformResolved } = require('../util/Util.js');
|
|
22
|
-
const { Attachment } = require('./Attachment.js');
|
|
23
|
-
const { Base } = require('./Base.js');
|
|
24
|
-
const { ClientApplication } = require('./ClientApplication.js');
|
|
25
|
-
const { Embed } = require('./Embed.js');
|
|
26
|
-
const { InteractionCollector } = require('./InteractionCollector.js');
|
|
27
|
-
const { MessageMentions } = require('./MessageMentions.js');
|
|
28
|
-
const { MessagePayload } = require('./MessagePayload.js');
|
|
14
|
+
const Attachment = require('./Attachment');
|
|
15
|
+
const Base = require('./Base');
|
|
16
|
+
const ClientApplication = require('./ClientApplication');
|
|
17
|
+
const Embed = require('./Embed');
|
|
18
|
+
const InteractionCollector = require('./InteractionCollector');
|
|
19
|
+
const Mentions = require('./MessageMentions');
|
|
20
|
+
const MessagePayload = require('./MessagePayload');
|
|
29
21
|
const { Poll } = require('./Poll.js');
|
|
30
|
-
const
|
|
31
|
-
const { Sticker } = require('./Sticker
|
|
22
|
+
const ReactionCollector = require('./ReactionCollector');
|
|
23
|
+
const { Sticker } = require('./Sticker');
|
|
24
|
+
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
25
|
+
const ReactionManager = require('../managers/ReactionManager');
|
|
26
|
+
const { createComponent, findComponentByCustomId } = require('../util/Components');
|
|
27
|
+
const { NonSystemMessageTypes, MaxBulkDeletableMessageAge, UndeletableMessageTypes } = require('../util/Constants');
|
|
28
|
+
const MessageFlagsBitField = require('../util/MessageFlagsBitField');
|
|
29
|
+
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
30
|
+
const { _transformAPIMessageInteractionMetadata } = require('../util/Transformers.js');
|
|
31
|
+
const { cleanContent, resolvePartialEmoji, transformResolved } = require('../util/Util');
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Represents a message on Discord.
|
|
35
|
-
*
|
|
36
35
|
* @extends {Base}
|
|
37
36
|
*/
|
|
38
37
|
class Message extends Base {
|
|
@@ -41,14 +40,12 @@ class Message extends Base {
|
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* The id of the channel the message was sent in
|
|
44
|
-
*
|
|
45
43
|
* @type {Snowflake}
|
|
46
44
|
*/
|
|
47
45
|
this.channelId = data.channel_id;
|
|
48
46
|
|
|
49
47
|
/**
|
|
50
48
|
* The id of the guild the message was sent in, if any
|
|
51
|
-
*
|
|
52
49
|
* @type {?Snowflake}
|
|
53
50
|
*/
|
|
54
51
|
this.guildId = data.guild_id ?? this.channel?.guild?.id ?? null;
|
|
@@ -59,14 +56,12 @@ class Message extends Base {
|
|
|
59
56
|
_patch(data) {
|
|
60
57
|
/**
|
|
61
58
|
* The message's id
|
|
62
|
-
*
|
|
63
59
|
* @type {Snowflake}
|
|
64
60
|
*/
|
|
65
61
|
this.id = data.id;
|
|
66
62
|
|
|
67
63
|
/**
|
|
68
64
|
* The timestamp the message was sent at
|
|
69
|
-
*
|
|
70
65
|
* @type {number}
|
|
71
66
|
*/
|
|
72
67
|
this.createdTimestamp = DiscordSnowflake.timestampFrom(this.id);
|
|
@@ -74,14 +69,12 @@ class Message extends Base {
|
|
|
74
69
|
if ('type' in data) {
|
|
75
70
|
/**
|
|
76
71
|
* The type of the message
|
|
77
|
-
*
|
|
78
72
|
* @type {?MessageType}
|
|
79
73
|
*/
|
|
80
74
|
this.type = data.type;
|
|
81
75
|
|
|
82
76
|
/**
|
|
83
77
|
* Whether or not this message was sent by Discord, not actually a user (e.g. pin notifications)
|
|
84
|
-
*
|
|
85
78
|
* @type {?boolean}
|
|
86
79
|
*/
|
|
87
80
|
this.system = !NonSystemMessageTypes.includes(this.type);
|
|
@@ -95,7 +88,6 @@ class Message extends Base {
|
|
|
95
88
|
* The content of the message.
|
|
96
89
|
* <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
|
|
97
90
|
* in a guild for messages that do not mention the client.</info>
|
|
98
|
-
*
|
|
99
91
|
* @type {?string}
|
|
100
92
|
*/
|
|
101
93
|
this.content = data.content;
|
|
@@ -106,7 +98,6 @@ class Message extends Base {
|
|
|
106
98
|
if ('author' in data) {
|
|
107
99
|
/**
|
|
108
100
|
* The author of the message
|
|
109
|
-
*
|
|
110
101
|
* @type {?User}
|
|
111
102
|
*/
|
|
112
103
|
this.author = this.client.users._add(data.author, !data.webhook_id);
|
|
@@ -117,7 +108,6 @@ class Message extends Base {
|
|
|
117
108
|
if ('pinned' in data) {
|
|
118
109
|
/**
|
|
119
110
|
* Whether or not this message is pinned
|
|
120
|
-
*
|
|
121
111
|
* @type {?boolean}
|
|
122
112
|
*/
|
|
123
113
|
this.pinned = Boolean(data.pinned);
|
|
@@ -128,7 +118,6 @@ class Message extends Base {
|
|
|
128
118
|
if ('tts' in data) {
|
|
129
119
|
/**
|
|
130
120
|
* Whether or not the message was Text-To-Speech
|
|
131
|
-
*
|
|
132
121
|
* @type {?boolean}
|
|
133
122
|
*/
|
|
134
123
|
this.tts = data.tts;
|
|
@@ -141,7 +130,6 @@ class Message extends Base {
|
|
|
141
130
|
* A random number or string used for checking message delivery
|
|
142
131
|
* <warn>This is only received after the message was sent successfully, and
|
|
143
132
|
* lost if re-fetched</warn>
|
|
144
|
-
*
|
|
145
133
|
* @type {?string}
|
|
146
134
|
*/
|
|
147
135
|
this.nonce = data.nonce;
|
|
@@ -154,7 +142,6 @@ class Message extends Base {
|
|
|
154
142
|
* An array of embeds in the message - e.g. YouTube Player.
|
|
155
143
|
* <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
|
|
156
144
|
* in a guild for messages that do not mention the client.</info>
|
|
157
|
-
*
|
|
158
145
|
* @type {Embed[]}
|
|
159
146
|
*/
|
|
160
147
|
this.embeds = data.embeds.map(embed => new Embed(embed));
|
|
@@ -167,7 +154,6 @@ class Message extends Base {
|
|
|
167
154
|
* An array of components in the message.
|
|
168
155
|
* <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
|
|
169
156
|
* in a guild for messages that do not mention the client.</info>
|
|
170
|
-
*
|
|
171
157
|
* @type {Component[]}
|
|
172
158
|
*/
|
|
173
159
|
this.components = data.components.map(component => createComponent(component));
|
|
@@ -180,7 +166,6 @@ class Message extends Base {
|
|
|
180
166
|
* A collection of attachments in the message - e.g. Pictures - mapped by their ids.
|
|
181
167
|
* <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
|
|
182
168
|
* in a guild for messages that do not mention the client.</info>
|
|
183
|
-
*
|
|
184
169
|
* @type {Collection<Snowflake, Attachment>}
|
|
185
170
|
*/
|
|
186
171
|
this.attachments = new Collection();
|
|
@@ -196,7 +181,6 @@ class Message extends Base {
|
|
|
196
181
|
if ('sticker_items' in data || 'stickers' in data) {
|
|
197
182
|
/**
|
|
198
183
|
* A collection of stickers in the message
|
|
199
|
-
*
|
|
200
184
|
* @type {Collection<Snowflake, Sticker>}
|
|
201
185
|
*/
|
|
202
186
|
this.stickers = new Collection(
|
|
@@ -210,7 +194,6 @@ class Message extends Base {
|
|
|
210
194
|
/**
|
|
211
195
|
* A generally increasing integer (there may be gaps or duplicates) that represents
|
|
212
196
|
* the approximate position of the message in a thread.
|
|
213
|
-
*
|
|
214
197
|
* @type {?number}
|
|
215
198
|
*/
|
|
216
199
|
this.position = data.position;
|
|
@@ -221,7 +204,6 @@ class Message extends Base {
|
|
|
221
204
|
if ('role_subscription_data' in data) {
|
|
222
205
|
/**
|
|
223
206
|
* Role subscription data found on {@link MessageType.RoleSubscriptionPurchase} messages.
|
|
224
|
-
*
|
|
225
207
|
* @typedef {Object} RoleSubscriptionData
|
|
226
208
|
* @property {Snowflake} roleSubscriptionListingId The id of the SKU and listing the user is subscribed to
|
|
227
209
|
* @property {string} tierName The name of the tier the user is subscribed to
|
|
@@ -232,7 +214,6 @@ class Message extends Base {
|
|
|
232
214
|
/**
|
|
233
215
|
* The data of the role subscription purchase or renewal.
|
|
234
216
|
* <info>This is present on {@link MessageType.RoleSubscriptionPurchase} messages.</info>
|
|
235
|
-
*
|
|
236
217
|
* @type {?RoleSubscriptionData}
|
|
237
218
|
*/
|
|
238
219
|
this.roleSubscriptionData = {
|
|
@@ -248,8 +229,7 @@ class Message extends Base {
|
|
|
248
229
|
if ('resolved' in data) {
|
|
249
230
|
/**
|
|
250
231
|
* Resolved data from auto-populated select menus.
|
|
251
|
-
*
|
|
252
|
-
* @type {?CommandInteractionResolvedData}
|
|
232
|
+
* @typedef {Object} CommandInteractionResolvedData
|
|
253
233
|
*/
|
|
254
234
|
this.resolved = transformResolved(
|
|
255
235
|
{ client: this.client, guild: this.guild, channel: this.channel },
|
|
@@ -263,7 +243,6 @@ class Message extends Base {
|
|
|
263
243
|
if (data.edited_timestamp) {
|
|
264
244
|
/**
|
|
265
245
|
* The timestamp the message was last edited at (if applicable)
|
|
266
|
-
*
|
|
267
246
|
* @type {?number}
|
|
268
247
|
*/
|
|
269
248
|
this.editedTimestamp = Date.parse(data.edited_timestamp);
|
|
@@ -274,7 +253,6 @@ class Message extends Base {
|
|
|
274
253
|
if ('reactions' in data) {
|
|
275
254
|
/**
|
|
276
255
|
* A manager of the reactions belonging to this message
|
|
277
|
-
*
|
|
278
256
|
* @type {ReactionManager}
|
|
279
257
|
*/
|
|
280
258
|
this.reactions = new ReactionManager(this);
|
|
@@ -287,24 +265,33 @@ class Message extends Base {
|
|
|
287
265
|
this.reactions ??= new ReactionManager(this);
|
|
288
266
|
}
|
|
289
267
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
268
|
+
if (!this.mentions) {
|
|
269
|
+
/**
|
|
270
|
+
* All valid mentions that the message contains
|
|
271
|
+
* @type {MessageMentions}
|
|
272
|
+
*/
|
|
273
|
+
this.mentions = new Mentions(
|
|
274
|
+
this,
|
|
275
|
+
data.mentions,
|
|
276
|
+
data.mention_roles,
|
|
277
|
+
data.mention_everyone,
|
|
278
|
+
data.mention_channels,
|
|
279
|
+
data.referenced_message?.author,
|
|
280
|
+
);
|
|
281
|
+
} else {
|
|
282
|
+
this.mentions = new Mentions(
|
|
283
|
+
this,
|
|
284
|
+
data.mentions ?? this.mentions.users,
|
|
285
|
+
data.mention_roles ?? this.mentions.roles,
|
|
286
|
+
data.mention_everyone ?? this.mentions.everyone,
|
|
287
|
+
data.mention_channels ?? this.mentions.crosspostedChannels,
|
|
288
|
+
data.referenced_message?.author ?? this.mentions.repliedUser,
|
|
289
|
+
);
|
|
290
|
+
}
|
|
303
291
|
|
|
304
292
|
if ('webhook_id' in data) {
|
|
305
293
|
/**
|
|
306
294
|
* The id of the webhook that sent the message, if applicable
|
|
307
|
-
*
|
|
308
295
|
* @type {?Snowflake}
|
|
309
296
|
*/
|
|
310
297
|
this.webhookId = data.webhook_id;
|
|
@@ -315,7 +302,6 @@ class Message extends Base {
|
|
|
315
302
|
if ('application' in data) {
|
|
316
303
|
/**
|
|
317
304
|
* Supplemental application information for group activities
|
|
318
|
-
*
|
|
319
305
|
* @type {?ClientApplication}
|
|
320
306
|
*/
|
|
321
307
|
this.groupActivityApplication = new ClientApplication(this.client, data.application);
|
|
@@ -326,7 +312,6 @@ class Message extends Base {
|
|
|
326
312
|
if ('application_id' in data) {
|
|
327
313
|
/**
|
|
328
314
|
* The id of the application of the interaction that sent this message, if any
|
|
329
|
-
*
|
|
330
315
|
* @type {?Snowflake}
|
|
331
316
|
*/
|
|
332
317
|
this.applicationId = data.application_id;
|
|
@@ -337,7 +322,6 @@ class Message extends Base {
|
|
|
337
322
|
if ('activity' in data) {
|
|
338
323
|
/**
|
|
339
324
|
* Group activity
|
|
340
|
-
*
|
|
341
325
|
* @type {?MessageActivity}
|
|
342
326
|
*/
|
|
343
327
|
this.activity = {
|
|
@@ -361,7 +345,6 @@ class Message extends Base {
|
|
|
361
345
|
if ('flags' in data) {
|
|
362
346
|
/**
|
|
363
347
|
* Flags that are applied to the message
|
|
364
|
-
*
|
|
365
348
|
* @type {Readonly<MessageFlagsBitField>}
|
|
366
349
|
*/
|
|
367
350
|
this.flags = new MessageFlagsBitField(data.flags).freeze();
|
|
@@ -372,12 +355,11 @@ class Message extends Base {
|
|
|
372
355
|
/**
|
|
373
356
|
* Reference data sent in a message that contains ids identifying the referenced message.
|
|
374
357
|
* This can be present in the following types of message:
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
358
|
+
* * Crossposted messages (`MessageFlags.Crossposted`)
|
|
359
|
+
* * {@link MessageType.ChannelPinnedMessage}
|
|
360
|
+
* * {@link MessageType.ChannelFollowAdd}
|
|
361
|
+
* * {@link MessageType.Reply}
|
|
362
|
+
* * {@link MessageType.ThreadStarterMessage}
|
|
381
363
|
* @see {@link https://discord.com/developers/docs/resources/message#message-object-message-types}
|
|
382
364
|
* @typedef {Object} MessageReference
|
|
383
365
|
* @property {Snowflake} channelId The channel id that was referenced
|
|
@@ -389,7 +371,6 @@ class Message extends Base {
|
|
|
389
371
|
if ('message_reference' in data) {
|
|
390
372
|
/**
|
|
391
373
|
* Message reference data
|
|
392
|
-
*
|
|
393
374
|
* @type {?MessageReference}
|
|
394
375
|
*/
|
|
395
376
|
this.reference = {
|
|
@@ -409,13 +390,12 @@ class Message extends Base {
|
|
|
409
390
|
if (data.interaction_metadata) {
|
|
410
391
|
/**
|
|
411
392
|
* Partial data of the interaction that a message is a result of
|
|
412
|
-
*
|
|
413
393
|
* @typedef {Object} MessageInteractionMetadata
|
|
414
394
|
* @property {Snowflake} id The interaction's id
|
|
415
395
|
* @property {InteractionType} type The type of the interaction
|
|
416
396
|
* @property {User} user The user that invoked the interaction
|
|
417
|
-
* @property {
|
|
418
|
-
*
|
|
397
|
+
* @property {APIAuthorizingIntegrationOwnersMap} authorizingIntegrationOwners
|
|
398
|
+
* Ids for installation context(s) related to an interaction
|
|
419
399
|
* @property {?Snowflake} originalResponseMessageId
|
|
420
400
|
* Id of the original response message. Present only on follow-up messages
|
|
421
401
|
* @property {?Snowflake} interactedMessageId
|
|
@@ -427,7 +407,6 @@ class Message extends Base {
|
|
|
427
407
|
|
|
428
408
|
/**
|
|
429
409
|
* Partial data of the interaction that this message is a result of
|
|
430
|
-
*
|
|
431
410
|
* @type {?MessageInteractionMetadata}
|
|
432
411
|
*/
|
|
433
412
|
this.interactionMetadata = _transformAPIMessageInteractionMetadata(this.client, data.interaction_metadata);
|
|
@@ -435,13 +414,39 @@ class Message extends Base {
|
|
|
435
414
|
this.interactionMetadata ??= null;
|
|
436
415
|
}
|
|
437
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Partial data of the interaction that a message is a reply to
|
|
419
|
+
* @typedef {Object} MessageInteraction
|
|
420
|
+
* @property {Snowflake} id The interaction's id
|
|
421
|
+
* @property {InteractionType} type The type of the interaction
|
|
422
|
+
* @property {string} commandName The name of the interaction's application command,
|
|
423
|
+
* as well as the subcommand and subcommand group, where applicable
|
|
424
|
+
* @property {User} user The user that invoked the interaction
|
|
425
|
+
* @deprecated Use {@link Message#interactionMetadata} instead.
|
|
426
|
+
*/
|
|
427
|
+
|
|
428
|
+
if (data.interaction) {
|
|
429
|
+
/**
|
|
430
|
+
* Partial data of the interaction that this message is a reply to
|
|
431
|
+
* @type {?MessageInteraction}
|
|
432
|
+
* @deprecated Use {@link Message#interactionMetadata} instead.
|
|
433
|
+
*/
|
|
434
|
+
this.interaction = {
|
|
435
|
+
id: data.interaction.id,
|
|
436
|
+
type: data.interaction.type,
|
|
437
|
+
commandName: data.interaction.name,
|
|
438
|
+
user: this.client.users._add(data.interaction.user),
|
|
439
|
+
};
|
|
440
|
+
} else {
|
|
441
|
+
this.interaction ??= null;
|
|
442
|
+
}
|
|
443
|
+
|
|
438
444
|
if (data.poll) {
|
|
439
445
|
if (this.poll) {
|
|
440
446
|
this.poll._patch(data.poll);
|
|
441
447
|
} else {
|
|
442
448
|
/**
|
|
443
449
|
* The poll that was sent with the message
|
|
444
|
-
*
|
|
445
450
|
* @type {?Poll}
|
|
446
451
|
*/
|
|
447
452
|
this.poll = new Poll(this.client, data.poll, this, this.channel);
|
|
@@ -453,7 +458,6 @@ class Message extends Base {
|
|
|
453
458
|
if (data.message_snapshots) {
|
|
454
459
|
/**
|
|
455
460
|
* The message snapshots associated with the message reference
|
|
456
|
-
*
|
|
457
461
|
* @type {Collection<Snowflake, Message>}
|
|
458
462
|
*/
|
|
459
463
|
this.messageSnapshots = data.message_snapshots.reduce((coll, snapshot) => {
|
|
@@ -476,7 +480,6 @@ class Message extends Base {
|
|
|
476
480
|
|
|
477
481
|
/**
|
|
478
482
|
* A call associated with a message
|
|
479
|
-
*
|
|
480
483
|
* @typedef {Object} MessageCall
|
|
481
484
|
* @property {Readonly<?Date>} endedAt The time the call ended
|
|
482
485
|
* @property {?number} endedTimestamp The timestamp the call ended
|
|
@@ -486,7 +489,6 @@ class Message extends Base {
|
|
|
486
489
|
if (data.call) {
|
|
487
490
|
/**
|
|
488
491
|
* The call associated with the message
|
|
489
|
-
*
|
|
490
492
|
* @type {?MessageCall}
|
|
491
493
|
*/
|
|
492
494
|
this.call = {
|
|
@@ -499,39 +501,10 @@ class Message extends Base {
|
|
|
499
501
|
} else {
|
|
500
502
|
this.call ??= null;
|
|
501
503
|
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* The shared client theme sent with this message
|
|
505
|
-
*
|
|
506
|
-
* @typedef {Object} SharedClientTheme
|
|
507
|
-
* @property {string[]} colors The hexadecimal-encoded colors of the theme (max of 5)
|
|
508
|
-
* @property {number} gradientAngle The direction of the theme's colors (0–360)
|
|
509
|
-
* @property {number} baseMix The intensity of the theme's colors (0–100)
|
|
510
|
-
* @property {?BaseThemeType} [baseTheme] The mode of the theme
|
|
511
|
-
*/
|
|
512
|
-
if (data.shared_client_theme) {
|
|
513
|
-
/**
|
|
514
|
-
* The shared client theme sent with this message
|
|
515
|
-
*
|
|
516
|
-
* @type {?SharedClientTheme}
|
|
517
|
-
*/
|
|
518
|
-
this.sharedClientTheme = {
|
|
519
|
-
colors: data.shared_client_theme.colors,
|
|
520
|
-
gradientAngle: data.shared_client_theme.gradient_angle,
|
|
521
|
-
baseMix: data.shared_client_theme.base_mix,
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
if ('base_theme' in data.shared_client_theme) {
|
|
525
|
-
this.sharedClientTheme.baseTheme = data.shared_client_theme.base_theme;
|
|
526
|
-
}
|
|
527
|
-
} else {
|
|
528
|
-
this.sharedClientTheme ??= null;
|
|
529
|
-
}
|
|
530
504
|
}
|
|
531
505
|
|
|
532
506
|
/**
|
|
533
507
|
* The channel that the message was sent in
|
|
534
|
-
*
|
|
535
508
|
* @type {TextBasedChannels}
|
|
536
509
|
* @readonly
|
|
537
510
|
*/
|
|
@@ -541,7 +514,6 @@ class Message extends Base {
|
|
|
541
514
|
|
|
542
515
|
/**
|
|
543
516
|
* Whether or not this message is a partial
|
|
544
|
-
*
|
|
545
517
|
* @type {boolean}
|
|
546
518
|
* @readonly
|
|
547
519
|
*/
|
|
@@ -552,7 +524,6 @@ class Message extends Base {
|
|
|
552
524
|
/**
|
|
553
525
|
* Represents the author of the message as a guild member.
|
|
554
526
|
* Only available if the message comes from a guild where the author is still a member
|
|
555
|
-
*
|
|
556
527
|
* @type {?GuildMember}
|
|
557
528
|
* @readonly
|
|
558
529
|
*/
|
|
@@ -562,7 +533,6 @@ class Message extends Base {
|
|
|
562
533
|
|
|
563
534
|
/**
|
|
564
535
|
* The time the message was sent at
|
|
565
|
-
*
|
|
566
536
|
* @type {Date}
|
|
567
537
|
* @readonly
|
|
568
538
|
*/
|
|
@@ -572,7 +542,6 @@ class Message extends Base {
|
|
|
572
542
|
|
|
573
543
|
/**
|
|
574
544
|
* The time the message was last edited at (if applicable)
|
|
575
|
-
*
|
|
576
545
|
* @type {?Date}
|
|
577
546
|
* @readonly
|
|
578
547
|
*/
|
|
@@ -582,7 +551,6 @@ class Message extends Base {
|
|
|
582
551
|
|
|
583
552
|
/**
|
|
584
553
|
* The guild the message was sent in (if in a guild channel)
|
|
585
|
-
*
|
|
586
554
|
* @type {?Guild}
|
|
587
555
|
* @readonly
|
|
588
556
|
*/
|
|
@@ -592,7 +560,6 @@ class Message extends Base {
|
|
|
592
560
|
|
|
593
561
|
/**
|
|
594
562
|
* Whether this message has a thread associated with it
|
|
595
|
-
*
|
|
596
563
|
* @type {boolean}
|
|
597
564
|
* @readonly
|
|
598
565
|
*/
|
|
@@ -604,7 +571,6 @@ class Message extends Base {
|
|
|
604
571
|
* The thread started by this message
|
|
605
572
|
* <info>This property is not suitable for checking whether a message has a thread,
|
|
606
573
|
* use {@link Message#hasThread} instead.</info>
|
|
607
|
-
*
|
|
608
574
|
* @type {?ThreadChannel}
|
|
609
575
|
* @readonly
|
|
610
576
|
*/
|
|
@@ -614,7 +580,6 @@ class Message extends Base {
|
|
|
614
580
|
|
|
615
581
|
/**
|
|
616
582
|
* The URL to jump to this message
|
|
617
|
-
*
|
|
618
583
|
* @type {string}
|
|
619
584
|
* @readonly
|
|
620
585
|
*/
|
|
@@ -625,7 +590,6 @@ class Message extends Base {
|
|
|
625
590
|
/**
|
|
626
591
|
* The message contents with all mentions replaced by the equivalent text.
|
|
627
592
|
* If mentions cannot be resolved to a name, the relevant mention in the message content will not be converted.
|
|
628
|
-
*
|
|
629
593
|
* @type {?string}
|
|
630
594
|
* @readonly
|
|
631
595
|
*/
|
|
@@ -636,7 +600,6 @@ class Message extends Base {
|
|
|
636
600
|
|
|
637
601
|
/**
|
|
638
602
|
* Creates a reaction collector.
|
|
639
|
-
*
|
|
640
603
|
* @param {ReactionCollectorOptions} [options={}] Options to send to the collector
|
|
641
604
|
* @returns {ReactionCollector}
|
|
642
605
|
* @example
|
|
@@ -652,7 +615,6 @@ class Message extends Base {
|
|
|
652
615
|
|
|
653
616
|
/**
|
|
654
617
|
* An object containing the same properties as CollectorOptions, but a few more:
|
|
655
|
-
*
|
|
656
618
|
* @typedef {ReactionCollectorOptions} AwaitReactionsOptions
|
|
657
619
|
* @property {string[]} [errors] Stop/end reasons that cause the promise to reject
|
|
658
620
|
*/
|
|
@@ -660,7 +622,6 @@ class Message extends Base {
|
|
|
660
622
|
/**
|
|
661
623
|
* Similar to createReactionCollector but in promise form.
|
|
662
624
|
* Resolves with a collection of reactions that pass the specified filter.
|
|
663
|
-
*
|
|
664
625
|
* @param {AwaitReactionsOptions} [options={}] Optional options to pass to the internal collector
|
|
665
626
|
* @returns {Promise<Collection<string|Snowflake, MessageReaction>>}
|
|
666
627
|
* @example
|
|
@@ -670,7 +631,7 @@ class Message extends Base {
|
|
|
670
631
|
* .then(collected => console.log(`Collected ${collected.size} reactions`))
|
|
671
632
|
* .catch(console.error);
|
|
672
633
|
*/
|
|
673
|
-
|
|
634
|
+
awaitReactions(options = {}) {
|
|
674
635
|
return new Promise((resolve, reject) => {
|
|
675
636
|
const collector = this.createReactionCollector(options);
|
|
676
637
|
collector.once('end', (reactions, reason) => {
|
|
@@ -690,7 +651,6 @@ class Message extends Base {
|
|
|
690
651
|
|
|
691
652
|
/**
|
|
692
653
|
* Creates a message component interaction collector.
|
|
693
|
-
*
|
|
694
654
|
* @param {MessageComponentCollectorOptions} [options={}] Options to send to the collector
|
|
695
655
|
* @returns {InteractionCollector}
|
|
696
656
|
* @example
|
|
@@ -710,19 +670,18 @@ class Message extends Base {
|
|
|
710
670
|
|
|
711
671
|
/**
|
|
712
672
|
* An object containing the same properties as CollectorOptions, but a few more:
|
|
713
|
-
*
|
|
714
673
|
* @typedef {Object} AwaitMessageComponentOptions
|
|
715
674
|
* @property {CollectorFilter} [filter] The filter applied to this collector
|
|
716
675
|
* @property {number} [time] Time to wait for an interaction before rejecting
|
|
717
676
|
* @property {ComponentType} [componentType] The type of component interaction to collect
|
|
718
677
|
* @property {number} [idle] Time to wait without another message component interaction before ending the collector
|
|
719
678
|
* @property {boolean} [dispose] Whether to remove the message component interaction after collecting
|
|
679
|
+
* @property {InteractionResponse} [interactionResponse] The interaction response to collect interactions from
|
|
720
680
|
*/
|
|
721
681
|
|
|
722
682
|
/**
|
|
723
683
|
* Collects a single component interaction that passes the filter.
|
|
724
684
|
* The Promise will reject if the time expires.
|
|
725
|
-
*
|
|
726
685
|
* @param {AwaitMessageComponentOptions} [options={}] Options to pass to the internal collector
|
|
727
686
|
* @returns {Promise<MessageComponentInteraction>}
|
|
728
687
|
* @example
|
|
@@ -732,7 +691,7 @@ class Message extends Base {
|
|
|
732
691
|
* .then(interaction => console.log(`${interaction.customId} was clicked!`))
|
|
733
692
|
* .catch(console.error);
|
|
734
693
|
*/
|
|
735
|
-
|
|
694
|
+
awaitMessageComponent(options = {}) {
|
|
736
695
|
const _options = { ...options, max: 1 };
|
|
737
696
|
return new Promise((resolve, reject) => {
|
|
738
697
|
const collector = this.createMessageComponentCollector(_options);
|
|
@@ -746,7 +705,6 @@ class Message extends Base {
|
|
|
746
705
|
|
|
747
706
|
/**
|
|
748
707
|
* Whether the message is editable by the client user
|
|
749
|
-
*
|
|
750
708
|
* @type {boolean}
|
|
751
709
|
* @readonly
|
|
752
710
|
*/
|
|
@@ -772,7 +730,6 @@ class Message extends Base {
|
|
|
772
730
|
|
|
773
731
|
/**
|
|
774
732
|
* Whether the message is deletable by the client user
|
|
775
|
-
*
|
|
776
733
|
* @type {boolean}
|
|
777
734
|
* @readonly
|
|
778
735
|
*/
|
|
@@ -782,7 +739,6 @@ class Message extends Base {
|
|
|
782
739
|
if (!this.guild) {
|
|
783
740
|
return this.author.id === this.client.user.id;
|
|
784
741
|
}
|
|
785
|
-
|
|
786
742
|
// DMChannel does not have viewable property, so check viewable after proved that message is on a guild.
|
|
787
743
|
if (!this.channel?.viewable) {
|
|
788
744
|
return false;
|
|
@@ -802,7 +758,6 @@ class Message extends Base {
|
|
|
802
758
|
|
|
803
759
|
/**
|
|
804
760
|
* Whether the message is bulk deletable by the client user
|
|
805
|
-
*
|
|
806
761
|
* @type {boolean}
|
|
807
762
|
* @readonly
|
|
808
763
|
* @example
|
|
@@ -821,18 +776,16 @@ class Message extends Base {
|
|
|
821
776
|
|
|
822
777
|
/**
|
|
823
778
|
* Whether the message is pinnable by the client user
|
|
824
|
-
*
|
|
825
779
|
* @type {boolean}
|
|
826
780
|
* @readonly
|
|
827
781
|
*/
|
|
828
782
|
get pinnable() {
|
|
829
783
|
const { channel } = this;
|
|
830
|
-
|
|
831
784
|
if (this.system) return false;
|
|
832
785
|
if (!this.guild) return true;
|
|
833
786
|
if (!channel || channel.isVoiceBased() || !channel.viewable) return false;
|
|
834
787
|
|
|
835
|
-
const permissions = channel
|
|
788
|
+
const permissions = channel?.permissionsFor(this.client.user);
|
|
836
789
|
if (!permissions) return false;
|
|
837
790
|
|
|
838
791
|
return permissions.has(PermissionFlagsBits.ReadMessageHistory | PermissionFlagsBits.PinMessages);
|
|
@@ -840,7 +793,6 @@ class Message extends Base {
|
|
|
840
793
|
|
|
841
794
|
/**
|
|
842
795
|
* Fetches the Message this crosspost/reply/pin-add references, if available to the client
|
|
843
|
-
*
|
|
844
796
|
* @returns {Promise<Message>}
|
|
845
797
|
*/
|
|
846
798
|
async fetchReference() {
|
|
@@ -849,12 +801,12 @@ class Message extends Base {
|
|
|
849
801
|
if (!messageId) throw new DiscordjsError(ErrorCodes.MessageReferenceMissing);
|
|
850
802
|
const channel = this.client.channels.resolve(channelId);
|
|
851
803
|
if (!channel) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
|
|
852
|
-
|
|
804
|
+
const message = await channel.messages.fetch(messageId);
|
|
805
|
+
return message;
|
|
853
806
|
}
|
|
854
807
|
|
|
855
808
|
/**
|
|
856
809
|
* Whether the message is crosspostable by the client user
|
|
857
|
-
*
|
|
858
810
|
* @type {boolean}
|
|
859
811
|
* @readonly
|
|
860
812
|
*/
|
|
@@ -876,8 +828,7 @@ class Message extends Base {
|
|
|
876
828
|
|
|
877
829
|
/**
|
|
878
830
|
* Edits the content of the message.
|
|
879
|
-
*
|
|
880
|
-
* @param {string|MessageEditOptions|MessagePayload|FileBodyEncodable<RESTPatchAPIChannelMessageJSONBody>|JSONEncodable<RESTPatchAPIChannelMessageJSONBody>} options The options to provide
|
|
831
|
+
* @param {string|MessagePayload|MessageEditOptions} options The options to provide
|
|
881
832
|
* @returns {Promise<Message>}
|
|
882
833
|
* @example
|
|
883
834
|
* // Update the content of a message
|
|
@@ -892,7 +843,6 @@ class Message extends Base {
|
|
|
892
843
|
|
|
893
844
|
/**
|
|
894
845
|
* Publishes a message in an announcement channel to all channels following it.
|
|
895
|
-
*
|
|
896
846
|
* @returns {Promise<Message>}
|
|
897
847
|
* @example
|
|
898
848
|
* // Crosspost a message
|
|
@@ -909,7 +859,6 @@ class Message extends Base {
|
|
|
909
859
|
|
|
910
860
|
/**
|
|
911
861
|
* Pins this message to the channel's pinned messages.
|
|
912
|
-
*
|
|
913
862
|
* @param {string} [reason] Reason for pinning
|
|
914
863
|
* @returns {Promise<Message>}
|
|
915
864
|
* @example
|
|
@@ -926,7 +875,6 @@ class Message extends Base {
|
|
|
926
875
|
|
|
927
876
|
/**
|
|
928
877
|
* Unpins this message from the channel's pinned messages.
|
|
929
|
-
*
|
|
930
878
|
* @param {string} [reason] Reason for unpinning
|
|
931
879
|
* @returns {Promise<Message>}
|
|
932
880
|
* @example
|
|
@@ -943,7 +891,6 @@ class Message extends Base {
|
|
|
943
891
|
|
|
944
892
|
/**
|
|
945
893
|
* Adds a reaction to the message.
|
|
946
|
-
*
|
|
947
894
|
* @param {EmojiIdentifierResolvable} emoji The emoji to react with
|
|
948
895
|
* @returns {Promise<MessageReaction>}
|
|
949
896
|
* @example
|
|
@@ -974,7 +921,6 @@ class Message extends Base {
|
|
|
974
921
|
|
|
975
922
|
/**
|
|
976
923
|
* Deletes the message.
|
|
977
|
-
*
|
|
978
924
|
* @returns {Promise<Message>}
|
|
979
925
|
* @example
|
|
980
926
|
* // Delete a message
|
|
@@ -990,7 +936,6 @@ class Message extends Base {
|
|
|
990
936
|
|
|
991
937
|
/**
|
|
992
938
|
* Options provided when sending a message as an inline reply.
|
|
993
|
-
*
|
|
994
939
|
* @typedef {BaseMessageCreateOptions} MessageReplyOptions
|
|
995
940
|
* @property {boolean} [failIfNotExists=this.client.options.failIfNotExists] Whether to error if the referenced
|
|
996
941
|
* message does not exist (creates a standard message in this case when false)
|
|
@@ -998,7 +943,6 @@ class Message extends Base {
|
|
|
998
943
|
|
|
999
944
|
/**
|
|
1000
945
|
* Send an inline reply to this message.
|
|
1001
|
-
*
|
|
1002
946
|
* @param {string|MessagePayload|MessageReplyOptions} options The options to provide
|
|
1003
947
|
* @returns {Promise<Message>}
|
|
1004
948
|
* @example
|
|
@@ -1008,45 +952,42 @@ class Message extends Base {
|
|
|
1008
952
|
* .catch(console.error);
|
|
1009
953
|
*/
|
|
1010
954
|
async reply(options) {
|
|
955
|
+
if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
|
|
1011
956
|
let data;
|
|
1012
957
|
|
|
1013
958
|
if (options instanceof MessagePayload) {
|
|
1014
959
|
data = options;
|
|
1015
960
|
} else {
|
|
1016
961
|
data = MessagePayload.create(this, options, {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
channelId: this.channelId,
|
|
1020
|
-
guildId: this.guildId ?? undefined,
|
|
1021
|
-
type: MessageReferenceType.Default,
|
|
962
|
+
reply: {
|
|
963
|
+
messageReference: this,
|
|
1022
964
|
failIfNotExists: options?.failIfNotExists ?? this.client.options.failIfNotExists,
|
|
1023
965
|
},
|
|
1024
966
|
});
|
|
1025
967
|
}
|
|
1026
|
-
|
|
1027
|
-
return this.client.channels.createMessage(this.channelId, data);
|
|
968
|
+
return this.channel.send(data);
|
|
1028
969
|
}
|
|
1029
970
|
|
|
1030
971
|
/**
|
|
1031
|
-
* Forwards this message
|
|
972
|
+
* Forwards this message
|
|
1032
973
|
*
|
|
1033
|
-
* @param {
|
|
974
|
+
* @param {TextBasedChannelResolvable} channel The channel to forward this message to.
|
|
1034
975
|
* @returns {Promise<Message>}
|
|
1035
976
|
*/
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
977
|
+
forward(channel) {
|
|
978
|
+
const resolvedChannel = this.client.channels.resolve(channel);
|
|
979
|
+
if (!resolvedChannel) throw new DiscordjsError(ErrorCodes.InvalidType, 'channel', 'TextBasedChannelResolvable');
|
|
980
|
+
return resolvedChannel.send({
|
|
981
|
+
forward: {
|
|
982
|
+
message: this.id,
|
|
983
|
+
channel: this.channelId,
|
|
984
|
+
guild: this.guildId,
|
|
1043
985
|
},
|
|
1044
986
|
});
|
|
1045
987
|
}
|
|
1046
988
|
|
|
1047
989
|
/**
|
|
1048
990
|
* Options for starting a thread on a message.
|
|
1049
|
-
*
|
|
1050
991
|
* @typedef {Object} StartThreadOptions
|
|
1051
992
|
* @property {string} name The name of the new thread
|
|
1052
993
|
* @property {ThreadAutoArchiveDuration} [autoArchiveDuration=this.channel.defaultAutoArchiveDuration] The amount of
|
|
@@ -1057,7 +998,6 @@ class Message extends Base {
|
|
|
1057
998
|
|
|
1058
999
|
/**
|
|
1059
1000
|
* Create a new public thread from this message
|
|
1060
|
-
*
|
|
1061
1001
|
* @see GuildTextThreadManager#create
|
|
1062
1002
|
* @param {StartThreadOptions} [options] Options for starting a thread on this message
|
|
1063
1003
|
* @returns {Promise<ThreadChannel>}
|
|
@@ -1067,14 +1007,12 @@ class Message extends Base {
|
|
|
1067
1007
|
if (![ChannelType.GuildText, ChannelType.GuildAnnouncement].includes(this.channel.type)) {
|
|
1068
1008
|
throw new DiscordjsError(ErrorCodes.MessageThreadParent);
|
|
1069
1009
|
}
|
|
1070
|
-
|
|
1071
1010
|
if (this.hasThread) throw new DiscordjsError(ErrorCodes.MessageExistingThread);
|
|
1072
1011
|
return this.channel.threads.create({ ...options, startMessage: this });
|
|
1073
1012
|
}
|
|
1074
1013
|
|
|
1075
1014
|
/**
|
|
1076
1015
|
* Fetch this message.
|
|
1077
|
-
*
|
|
1078
1016
|
* @param {boolean} [force=true] Whether to skip the cache check and request the API
|
|
1079
1017
|
* @returns {Promise<Message>}
|
|
1080
1018
|
*/
|
|
@@ -1085,7 +1023,6 @@ class Message extends Base {
|
|
|
1085
1023
|
|
|
1086
1024
|
/**
|
|
1087
1025
|
* Fetches the webhook used to create this message.
|
|
1088
|
-
*
|
|
1089
1026
|
* @returns {Promise<?Webhook>}
|
|
1090
1027
|
*/
|
|
1091
1028
|
async fetchWebhook() {
|
|
@@ -1096,11 +1033,10 @@ class Message extends Base {
|
|
|
1096
1033
|
|
|
1097
1034
|
/**
|
|
1098
1035
|
* Suppresses or unsuppresses embeds on a message.
|
|
1099
|
-
*
|
|
1100
1036
|
* @param {boolean} [suppress=true] If the embeds should be suppressed or not
|
|
1101
1037
|
* @returns {Promise<Message>}
|
|
1102
1038
|
*/
|
|
1103
|
-
|
|
1039
|
+
suppressEmbeds(suppress = true) {
|
|
1104
1040
|
const flags = new MessageFlagsBitField(this.flags.bitfield);
|
|
1105
1041
|
|
|
1106
1042
|
if (suppress) {
|
|
@@ -1114,16 +1050,14 @@ class Message extends Base {
|
|
|
1114
1050
|
|
|
1115
1051
|
/**
|
|
1116
1052
|
* Removes the attachments from this message.
|
|
1117
|
-
*
|
|
1118
1053
|
* @returns {Promise<Message>}
|
|
1119
1054
|
*/
|
|
1120
|
-
|
|
1055
|
+
removeAttachments() {
|
|
1121
1056
|
return this.edit({ attachments: [] });
|
|
1122
1057
|
}
|
|
1123
1058
|
|
|
1124
1059
|
/**
|
|
1125
1060
|
* Resolves a component by a custom id.
|
|
1126
|
-
*
|
|
1127
1061
|
* @param {string} customId The custom id to resolve against
|
|
1128
1062
|
* @returns {?MessageActionRowComponent}
|
|
1129
1063
|
*/
|
|
@@ -1135,9 +1069,8 @@ class Message extends Base {
|
|
|
1135
1069
|
* Used mainly internally. Whether two messages are identical in properties. If you want to compare messages
|
|
1136
1070
|
* without checking all the properties, use `message.id === message2.id`, which is much more efficient. This
|
|
1137
1071
|
* method allows you to see if there are differences in content, embeds, attachments, nonce and tts properties.
|
|
1138
|
-
*
|
|
1139
1072
|
* @param {Message} message The message to compare it to
|
|
1140
|
-
* @param {APIMessage}
|
|
1073
|
+
* @param {APIMessage} rawData Raw data passed through the WebSocket about this message
|
|
1141
1074
|
* @returns {boolean}
|
|
1142
1075
|
*/
|
|
1143
1076
|
equals(message, rawData) {
|
|
@@ -1168,7 +1101,6 @@ class Message extends Base {
|
|
|
1168
1101
|
|
|
1169
1102
|
/**
|
|
1170
1103
|
* Whether this message is from a guild.
|
|
1171
|
-
*
|
|
1172
1104
|
* @returns {boolean}
|
|
1173
1105
|
*/
|
|
1174
1106
|
inGuild() {
|
|
@@ -1177,7 +1109,6 @@ class Message extends Base {
|
|
|
1177
1109
|
|
|
1178
1110
|
/**
|
|
1179
1111
|
* When concatenated with a string, this automatically concatenates the message's content instead of the object.
|
|
1180
|
-
*
|
|
1181
1112
|
* @returns {string}
|
|
1182
1113
|
* @example
|
|
1183
1114
|
* // Logs: Message: This is a message!
|