Skip to main content

@sapphire/discord.js-utilities

Classes

ClassDescription
InteractionOptionResolverUtility class for resolving command interaction options while working with the raw API. Based on https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/CommandInteractionOptionResolver.js
LazyPaginatedMessageThis is a LazyPaginatedMessage. Instead of resolving all pages that are functions on PaginatedMessage.run will resolve when requested.
MessageBuilderA message builder class, it implements the MessageCreateOptions interface.
MessagePrompterThis is a MessagePrompter, a utility that sends a message, prompting for user input. The prompt can resolve to any kind of input. There are several specifiable types to prompt for user input, and they are as follows: - Confirm This will send a simple Yes/No prompt, using reactions. - Number This will prompt for an integer. By default it will be a number between 0 and 10 (inclusive), however you can also specify your own custom range (inclusive). - Reactions This can be any kind of reaction emoji that Discord supports, and as many as you want. This type will return that reaction instead of a boolean. - Message This will prompt the user and require a response in the form of a message. This can be helpful if you require a user to upload an image for example, or give text input.
MessagePrompterBaseStrategy-
MessagePrompterConfirmStrategy-
MessagePrompterMessageStrategy-
MessagePrompterNumberStrategy-
MessagePrompterReactionStrategy-
PaginatedFieldMessageEmbedThis is a utility of PaginatedMessage, except it exclusively adds pagination inside a field of an embed. You must either use this class directly or extend it.
PaginatedMessageThis is a PaginatedMessage, a utility to paginate messages (usually embeds). You must either use this class directly or extend it.
PaginatedMessageEmbedFieldsThis is a utility of PaginatedMessage, except it exclusively paginates the fields of an embed. You must either use this class directly or extend it.

Interfaces

InterfaceDescription
IMessagePrompterConfirmStrategyOptions-
IMessagePrompterExplicitConfirmReturn-
IMessagePrompterExplicitMessageReturn-
IMessagePrompterExplicitNumberReturn-
IMessagePrompterExplicitReturnBase-
IMessagePrompterNumberStrategyOptions-
IMessagePrompterReactionStrategyOptions-
IMessagePrompterStrategyOptions-
PaginatedMessageActionContextThe context to be used in PaginatedMessageActionButton.
PaginatedMessageActionRunRepresents an action that can be run in a paginated message.
PaginatedMessageInternationalizationContextThis is a duplicate of the same interface in @sapphire/plugin-i18next Duplicated here for the type of the parameters in the functions
PaginatedMessageOptionsOptions for configuring a paginated message.
SafeReplyToInteractionParametersRepresents the parameters for safely replying to an interaction.
StrategyFilters-
StrategyOptions-
StrategyReturns-

Type Aliases

Type aliasDescription
AnyInteractableInteractionA union of ChatInputCommandInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, StringSelectMenuInteraction, ButtonInteraction, and ModalSubmitInteraction
AnyInteractionA union of ChatInputCommandInteractionUserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, AutocompleteInteraction, StringSelectMenuInteraction, ButtonInteraction, and ModalSubmitInteraction
ChannelTypeStringThe types of a channel, with the addition of 'UNKNOWN'
ChannelTypesA union of all the various types of channels that Discord.js has
ChatInputOrContextMenuCommandInteractionA union of ChatInputCommandInteraction, UserContextMenuCommandInteraction and MessageContextMenuCommandInteraction. Similar to CommandInteraction class but as a type union.
EmbedResolvableRepresents a resolvable object that can be used to create an embed in Discord. It can be either a JSON-encodable object or an APIEmbed object.
GuildBasedChannelTypesA union of all the channel types that belong to a guild, including ThreadChannel
GuildTextBasedChannelTypesA union of guild based message channels, including ThreadChannel
MessageBuilderFileResolvable-
MessageBuilderResolvable-
MessagePrompterChannelTypes-
MessagePrompterMessageA type to extend multiple discord types and simplify usage in MessagePrompter
NonModalInteractionA union of ChatInputCommandInteractionUserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, AutocompleteInteraction, StringSelectMenuInteraction and ButtonInteraction
NonThreadGuildBasedChannelTypesA union of all the channel types that belong to a guild, not including ThreadChannel
NonThreadGuildTextBasedChannelTypesA union of guild based message channels, not including ThreadChannel
PaginatedMessageActionRepresents an action that can be performed in a paginated message.
PaginatedMessageActionButtonTo utilize buttons you can pass an object with the structure of PaginatedMessageActionButton to PaginatedMessage actions.
PaginatedMessageActionChannelMenuTo utilize Channel Select Menus you can pass an object with the structure of PaginatedMessageActionChannelMenu to PaginatedMessage actions.
PaginatedMessageActionLinkTo utilize links you can pass an object with the structure of PaginatedMessageActionLink to PaginatedMessage actions.
PaginatedMessageActionMentionableMenuTo utilize Mentionable Select Menus you can pass an object with the structure of PaginatedMessageActionMentionableMenu to PaginatedMessage actions.
PaginatedMessageActionRoleMenuTo utilize Role Select Menus you can pass an object with the structure of PaginatedMessageActionRoleMenu to PaginatedMessage actions.
PaginatedMessageActionStringMenuTo utilize String Select Menus you can pass an object with the structure of PaginatedMessageActionStringMenu to PaginatedMessage actions.
PaginatedMessageActionUserMenuTo utilize User Select Menus you can pass an object with the structure of PaginatedMessageActionUserMenu to PaginatedMessage actions.
PaginatedMessageComponentUnionRepresents a union type for components in a paginated message. It can be one of the following types: - JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> - `ActionRowData<ActionRowComponentOptions
PaginatedMessageEmbedResolvableRepresents the resolvable type for the embeds property of a paginated message.
PaginatedMessageInteractionUnionRepresents the union type of interactions for a paginated message, excluding the ModalSubmitInteraction.
PaginatedMessageMessageOptionsUnionRepresents the union of options for a paginated message.
PaginatedMessagePageThe pages that are used for PaginatedMessage.pages
PaginatedMessageResolvedPageRepresents a resolved page for a paginated message. It can be either a BaseMessageOptions object with the flags property omitted, or a WebhookMessageEditOptions object.
PaginatedMessageSelectMenuOptionsFunctionThe type of the custom function that can be set for the PaginatedMessage.selectMenuOptions
PaginatedMessageStopReasonsRepresents the possible reasons for stopping a paginated message.
PaginatedMessageWriteableEmbedResolvableA non nullable writeable variant of PaginatedMessageEmbedResolvable. This removes:
PaginatedMessageWrongUserInteractionReplyFunctionThe type of the custom function that can be set for the PaginatedMessage.wrongUserInteractionReply
TextBasedChannelTypesA union of all the channel types that a message can come from
VoiceBasedChannelTypesA union of all the voice-based channel types that Discord.js has

Variables

VariableDescription
ActionMetadataLimitsNamespace containing limits related to Discord Auto Moderation Action Metadata.
AllowedMentionsLimitsNamespace containing limits related to Discord Message Allowed Mentions.
ApplicationCommandLimitsNamespace containing limits related to Discord application commands (slash commands).
ApplicationCommandOptionLimitsNamespace containing limits related to Choices of Discord Application Commands.
ApplicationCommandPermissionLimitsNamespace containing limits related to Permissions of Discord Application Commands.
ApplicationRoleConnectionLimitsNamespace containing limits related to Discord Application Role Connections.
AutoCompleteLimitsNamespace container limits related to Discord autocomplete interactions.
AutoModerationRuleLimitsNamespace containing limits related to Discord Auto Moderation Rules.
ButtonLimitsNamespace containing limits related to Message Buttons.
ChannelInviteLimitsNamespace containing limits related to Discord Channel Invites.
ChannelLimitsNamespace containing limits related to Discord channels.
ChannelMentionRegexRegex that can capture the ID in Discord Channel mentions
ChannelMessageRegexRegex that can capture the channel and message IDs in a channelId-messageId pattern This pattern can be found when you hold Shift and hover over a message, and click the "ID" button
DiscordHostnameRegexRegex that matches links on the known Discord host names
DiscordInviteLinkRegexRegex that can can capture the code of Discord invite links
EmbedLimitsNamespace containing limits related to Discord embeds.
EmojiLimitsNamespace containing limits related to Discord emojis.
EmojiRegexRegex that can capture the ID of any animated or non-animated custom Discord emoji
FormattedCustomEmojiRegex that matches any animated or non-animated custom Discord emoji. Unlike EmojiRegex It can be a substring of a larger string.
FormattedCustomEmojiWithGroupsRegex that can capture any animated or non-animated custom Discord emoji. Similar to FormattedCustomEmoji and unlike EmojiRegex can also be a substring of a larger string.
GuildAuditLogsLimitsNamespace containing limits related to Discord Guild Audit Logs.
GuildBansLimitsNamespace containing limits related to Discord guild bans.
GuildIntegrationLimitsNamespace containing limits related to Discord Guild Integrations.
GuildLimitsNamespace containing limits related to Discord guilds.
GuildMemberLimitsNamespace containing limits related to Discord guild members.
GuildScheduledEventLimitsNamespace containing limits related to Discord guild scheduled events.
HttpUrlRegexRegex that matches any URL starting with http or https
InteractionLimitsNamespace containing limits related to Discord interactions.
MessageLimitsNamespace containing limits related to Discord messages.
MessageLinkRegexRegex that can capture the Guild, Channel, and Message ID based on a shareable Discord message link.
ModalLimitsNamespace containing limits related to Discord Modals.
ModerationLimitsNamespace containing limits related to built-in moderation features.
ParsedCustomEmojiRegex that matches any animated or non-animated custom Discord emoji *without the wrapping <...> symbols. This means that a string that matches this regex can directly be send inside a Discord message. Other than this difference it is similar to FormattedCustomEmoji.
ParsedCustomEmojiWithGroupsRegex that matches any animated or non-animated custom Discord emoji *without the wrapping <...> symbols. This means that a string that matches this regex can directly be send inside a Discord message. Other than this difference it is similar to FormattedCustomEmojiWithGroups.
PremiumGuildLimitsNamespace containing limits related to premium Discord guilds.
ReactionLimitsNamespace containing limits related to Discord message reactions.
RoleLimitsNamespace containing limits related to Discord roles.
RoleMentionRegexRegex that can capture the ID in Discord Role mentions
SelectMenuLimitsNamespace containing limits related to Select Menus.
SnowflakeRegexRegex that can capture any Discord Snowflake ID
StageChannelLimitsNamespace containing limits related to Discord stage channels.
StickerLimitsNamespace containing limits related to Discord Stickers.
TextChannelLimitsNamespace containing limits related to Discord text channels.
TextInputLimitsNamespace containing limits related to Discord Modal Text Input component.
ThreadLimitsNamespace containing limits related to Discord threads.
TokenRegexRegex that can capture a Discord Token
TriggerMetadataLimitsNamespace containing limits related to Discord Auto Moderation Trigger Metadata.
TriggerTypeLimitsNamespace containing limits related to Discord Auto Moderation Triggers.
TwemojiRegexRegex that can capture a Twemoji (Twitter Emoji)
UserLimitsNamespace containing limits related to Discord users and Direct Messages.
UserOrMemberMentionRegexRegex that can capture the ID of a user in Discord user mentions
VoiceChannelLimitsNamespace containing limits related to Discord voice channels.
WebSocketUrlRegexRegex that matches any WebSocket URL starting with ws or wss
WebhookRegexRegex that captures the Webhook ID and token from a Discord Webhook URL.

Functions

FunctionDescription
actionIsButtonOrMenuChecks if a PaginatedMessageAction is a button or menu.
actionIsLinkButtonChecks if a PaginatedMessageAction is a button with ButtonStyle.Link style link.
canJoinVoiceChannelDetermines whether the client can join the given voice based channel.
canReactDetermines whether or not we can send react to messages in a given channel.
canReadMessagesDetermines whether or not we can read messages in a given channel.
canRemoveAllReactionsDetermines whether or not we can remove reactions from messages in a given channel.
canSendAttachmentsDetermines whether or not we can send attachments in a given channel.
canSendEmbedsDetermines whether or not we can send embeds in a given channel.
canSendMessagesDetermines whether or not we can send messages in a given channel.
createPartitionedMessageRowCreates partitioned message rows based on the provided components.
isActionButtonChecks if the given action is a paginated message action button.
isActionChannelMenuChecks if the given action is a paginated message action channel menu.
isActionLinkChecks if the given action is a paginated message action link.
isActionMentionableMenuChecks if the given action is a paginated message action mentionable menu.
isActionRoleMenuChecks if the given action is a paginated message action role menu.
isActionStringMenuChecks if the given action is a paginated message action string menu.
isActionUserMenuChecks if the given action is a paginated message action user menu.
isAnyInteractableInteractionChecks whether the input messageOrInteraction is one of Message or any class that extends BaseInteraction As opposed to isAnyInteraction this also checks that the interaction can actually be interacted with by the user which means that this cannot be an AutocompleteInteraction. That said, this type guard filters the messageOrInteraction down to one of: - Interaction - ButtonInteraction - ChannelSelectMenuInteraction - ChatInputCommandInteraction - CommandInteraction - ContextMenuInteraction - MentionableSelectMenuInteraction - MessageComponentInteraction - MessageContextMenuCommandInteraction - ModalSubmitInteraction - RoleSelectMenuInteraction - SelectMenuInteraction - StringSelectMenuInteraction - UserContextMenuCommandInteraction - UserSelectMenuInteraction
isAnyInteractionChecks whether the input messageOrInteraction is one of Message or any class that extends BaseInteraction. This generally boils down to being one of: - Interaction - AutocompleteInteraction - ButtonInteraction - ChannelSelectMenuInteraction - ChatInputCommandInteraction - CommandInteraction - ContextMenuInteraction - MentionableSelectMenuInteraction - MessageComponentInteraction - MessageContextMenuCommandInteraction - ModalSubmitInteraction - RoleSelectMenuInteraction - SelectMenuInteraction - StringSelectMenuInteraction - UserContextMenuCommandInteraction - UserSelectMenuInteraction
isButtonComponentBuilderChecks if the given component is a button builder.
isCategoryChannelChecks whether a given channel is a CategoryChannel This checks for ChannelType.GuildCategory.
isDMChannelChecks whether a given channel is a DMChannel This checks for ChannelType.DM.
isGroupChannelChecks whether a given channel is a PartialGroupDMChannel This checks for ChannelType.GroupDM.
isGuildBasedChannelChecks if a channel comes from a guild. This checks that the channel is not ChannelType.DM.
isGuildBasedChannelByGuildKeyChecks whether or not a channel comes from a guild.
isGuildMemberChecks whether a given member is an instance of GuildMember, and not APIInteractionGuildMember, APIGuildMember, or Nullish
isImageAttachmentChecks whether an attachment is an image attachment, this is done so by checking the content type of the attachment, if the content type starts with image/ and the attachment has dimensions defined, it is considered an image attachment.
isMediaAttachmentChecks whether an attachment is a media attachment, this is done so by checking the content type of the attachment, if the content type starts with image/, video/ or audio/ it is considered a media attachment.
isMessageButtonInteractionDataChecks if the given interaction is a button interaction.
isMessageChannelSelectInteractionDataChecks if the given interaction is a channel select interaction.
isMessageInstanceChecks whether a given message is an instance of Message, and not APIMessage
isMessageMentionableSelectInteractionDataChecks if the given interaction is a mentionable select interaction.
isMessageRoleSelectInteractionDataChecks if the given interaction is a role select interaction.
isMessageStringSelectInteractionDataChecks if the given interaction is a string select interaction.
isMessageUserSelectInteractionDataChecks if the given interaction is a user select interaction.
isNewsChannelChecks whether a given channel is a NewsChannel. This checks for ChannelType.GuildAnnouncement.
isNewsThreadChannelChecks whether a given channel is an Announcement PublicThreadChannel This checks for ChannelType.AnnouncementThread.
isNsfwChannelChecks whether a given channel allows NSFW content or not
isPrivateThreadChannelChecks whether a given channel is a PrivateThreadChannel This checks for ChannelType.PrivateThread.
isPublicThreadChannelChecks whether a given channel is a PublicThreadChannel This checks for ChannelType.PublicThread.
isStageChannelChecks whether a given channel is a StageChannel This checks for ChannelType.GuildStageVoice.
isTextBasedChannelChecks whether a given channel is a TextBasedChannelTypes. This means it has a send method.
isTextChannelChecks whether a given channel is a TextChannel. This checks for ChannelType.GuildText.
isThreadChannelChecks whether a given channel is a ThreadChannel This checks for ChannelTypes.isThread().
isVoiceBasedChannelChecks whether a given channel is a VoiceBasedChannel. This checks for Channel.isVoiceBased().
isVoiceChannelChecks whether a given channel is a VoiceChannel This checks for ChannelType.GuildVoice.
safelyReplyToInteractionSafely replies to a message or interaction. This is primarily to save duplicated code in the main PaginatedMessage class