@sapphire/discord.js-utilities
Classes
Class | Description |
---|---|
InteractionOptionResolver | Utility 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 |
LazyPaginatedMessage | This is a LazyPaginatedMessage. Instead of resolving all pages that are functions on PaginatedMessage.run will resolve when requested. |
MessageBuilder | A message builder class, it implements the MessageCreateOptions interface. |
MessagePrompter | This 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 | - |
PaginatedFieldMessageEmbed | This 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. |
PaginatedMessage | This is a PaginatedMessage, a utility to paginate messages (usually embeds). You must either use this class directly or extend it. |
PaginatedMessageEmbedFields | This 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
Interface | Description |
---|---|
IMessagePrompterConfirmStrategyOptions | - |
IMessagePrompterExplicitConfirmReturn | - |
IMessagePrompterExplicitMessageReturn | - |
IMessagePrompterExplicitNumberReturn | - |
IMessagePrompterExplicitReturnBase | - |
IMessagePrompterNumberStrategyOptions | - |
IMessagePrompterReactionStrategyOptions | - |
IMessagePrompterStrategyOptions | - |
PaginatedMessageActionContext | The context to be used in PaginatedMessageActionButton. |
PaginatedMessageActionRun | Represents an action that can be run in a paginated message. |
PaginatedMessageInternationalizationContext | This is a duplicate of the same interface in @sapphire/plugin-i18next Duplicated here for the type of the parameters in the functions |
PaginatedMessageOptions | Options for configuring a paginated message. |
SafeReplyToInteractionParameters | Represents the parameters for safely replying to an interaction. |
StrategyFilters | - |
StrategyOptions | - |
StrategyReturns | - |
Type Aliases
Type alias | Description |
---|---|
AnyInteractableInteraction | A union of ChatInputCommandInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, StringSelectMenuInteraction, ButtonInteraction, and ModalSubmitInteraction |
AnyInteraction | A union of ChatInputCommandInteractionUserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, AutocompleteInteraction, StringSelectMenuInteraction, ButtonInteraction, and ModalSubmitInteraction |
ChannelTypes | A union of all the various types of channels that Discord.js has |
ChannelTypeString | The types of a channel, with the addition of 'UNKNOWN' |
ChatInputOrContextMenuCommandInteraction | A union of ChatInputCommandInteraction, UserContextMenuCommandInteraction and MessageContextMenuCommandInteraction. Similar to CommandInteraction class but as a type union. |
EmbedResolvable | Represents 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. |
GuildBasedChannelTypes | A union of all the channel types that belong to a guild, including ThreadChannel |
GuildTextBasedChannelTypes | A union of guild based message channels, including ThreadChannel |
MessageBuilderFileResolvable | - |
MessageBuilderResolvable | - |
MessagePrompterChannelTypes | - |
MessagePrompterMessage | A type to extend multiple discord types and simplify usage in MessagePrompter |
NonModalInteraction | A union of ChatInputCommandInteractionUserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, AutocompleteInteraction, StringSelectMenuInteraction and ButtonInteraction |
NonThreadGuildBasedChannelTypes | A union of all the channel types that belong to a guild, not including ThreadChannel |
NonThreadGuildTextBasedChannelTypes | A union of guild based message channels, not including ThreadChannel |
PaginatedMessageAction | Represents an action that can be performed in a paginated message. |
PaginatedMessageActionButton | To utilize buttons you can pass an object with the structure of PaginatedMessageActionButton to PaginatedMessage actions. |
PaginatedMessageActionChannelMenu | To utilize Channel Select Menus you can pass an object with the structure of PaginatedMessageActionChannelMenu to PaginatedMessage actions. |
PaginatedMessageActionLink | To utilize links you can pass an object with the structure of PaginatedMessageActionLink to PaginatedMessage actions. |
PaginatedMessageActionMentionableMenu | To utilize Mentionable Select Menus you can pass an object with the structure of PaginatedMessageActionMentionableMenu to PaginatedMessage actions. |
PaginatedMessageActionRoleMenu | To utilize Role Select Menus you can pass an object with the structure of PaginatedMessageActionRoleMenu to PaginatedMessage actions. |
PaginatedMessageActionStringMenu | To utilize String Select Menus you can pass an object with the structure of PaginatedMessageActionStringMenu to PaginatedMessage actions. |
PaginatedMessageActionUserMenu | To utilize User Select Menus you can pass an object with the structure of PaginatedMessageActionUserMenu to PaginatedMessage actions. |
PaginatedMessageComponentUnion | Represents a union type for components in a paginated message. It can be one of the following types: - JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> - `ActionRowData<ActionRowComponentOptions |
PaginatedMessageEmbedResolvable | Represents the resolvable type for the embeds property of a paginated message. |
PaginatedMessageInteractionUnion | Represents the union type of interactions for a paginated message, excluding the ModalSubmitInteraction. |
PaginatedMessageMessageOptionsUnion | Represents the union of options for a paginated message. |
PaginatedMessagePage | The pages that are used for PaginatedMessage.pages |
PaginatedMessageResolvedPage | Represents a resolved page for a paginated message. It can be either a BaseMessageOptions object with the flags property omitted, or a WebhookMessageEditOptions object. |
PaginatedMessageSelectMenuOptionsFunction | The type of the custom function that can be set for the PaginatedMessage.selectMenuOptions |
PaginatedMessageStopReasons | Represents the possible reasons for stopping a paginated message. |
PaginatedMessageWriteableEmbedResolvable | A non nullable writeable variant of PaginatedMessageEmbedResolvable. This removes: |
PaginatedMessageWrongUserInteractionReplyFunction | The type of the custom function that can be set for the PaginatedMessage.wrongUserInteractionReply |
TextBasedChannelTypes | A union of all the channel types that a message can come from |
VoiceBasedChannelTypes | A union of all the voice-based channel types that Discord.js has |
Variables
Variable | Description |
---|---|
ActionMetadataLimits | Namespace containing limits related to Discord Auto Moderation Action Metadata. |
AllowedMentionsLimits | Namespace containing limits related to Discord Message Allowed Mentions. |
ApplicationCommandLimits | Namespace containing limits related to Discord application commands (slash commands). |
ApplicationCommandOptionLimits | Namespace containing limits related to Choices of Discord Application Commands. |
ApplicationCommandPermissionLimits | Namespace containing limits related to Permissions of Discord Application Commands. |
ApplicationRoleConnectionLimits | Namespace containing limits related to Discord Application Role Connections. |
AutoCompleteLimits | Namespace container limits related to Discord autocomplete interactions. |
AutoModerationRuleLimits | Namespace containing limits related to Discord Auto Moderation Rules. |
ButtonLimits | Namespace containing limits related to Message Buttons. |
ChannelInviteLimits | Namespace containing limits related to Discord Channel Invites. |
ChannelLimits | Namespace containing limits related to Discord channels. |
ChannelMentionRegex | Regex that can capture the ID in Discord Channel mentions |
ChannelMessageRegex | Regex 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 |
DiscordHostnameRegex | Regex that matches links on the known Discord host names |
DiscordInviteLinkRegex | Regex that can can capture the code of Discord invite links |
EmbedLimits | Namespace containing limits related to Discord embeds. |
EmojiLimits | Namespace containing limits related to Discord emojis. |
EmojiRegex | Regex that can capture the ID of any animated or non-animated custom Discord emoji |
FormattedCustomEmoji | Regex that matches any animated or non-animated custom Discord emoji. Unlike EmojiRegex It can be a substring of a larger string. |
FormattedCustomEmojiWithGroups | Regex 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. |
GuildAuditLogsLimits | Namespace containing limits related to Discord Guild Audit Logs. |
GuildBansLimits | Namespace containing limits related to Discord guild bans. |
GuildIntegrationLimits | Namespace containing limits related to Discord Guild Integrations. |
GuildLimits | Namespace containing limits related to Discord guilds. |
GuildMemberLimits | Namespace containing limits related to Discord guild members. |
GuildScheduledEventLimits | Namespace containing limits related to Discord guild scheduled events. |
HttpUrlRegex | Regex that matches any URL starting with http or https |
InteractionLimits | Namespace containing limits related to Discord interactions. |
MessageLimits | Namespace containing limits related to Discord messages. |
MessageLinkRegex | Regex that can capture the Guild, Channel, and Message ID based on a shareable Discord message link. |
ModalLimits | Namespace containing limits related to Discord Modals. |
ModerationLimits | Namespace containing limits related to built-in moderation features. |
ParsedCustomEmoji | Regex 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. |
ParsedCustomEmojiWithGroups | Regex 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. |
PremiumGuildLimits | Namespace containing limits related to premium Discord guilds. |
ReactionLimits | Namespace containing limits related to Discord message reactions. |
RoleLimits | Namespace containing limits related to Discord roles. |
RoleMentionRegex | Regex that can capture the ID in Discord Role mentions |
SelectMenuLimits | Namespace containing limits related to Select Menus. |
SnowflakeRegex | Regex that can capture any Discord Snowflake ID |
StageChannelLimits | Namespace containing limits related to Discord stage channels. |
StickerLimits | Namespace containing limits related to Discord Stickers. |
TextChannelLimits | Namespace containing limits related to Discord text channels. |
TextInputLimits | Namespace containing limits related to Discord Modal Text Input component. |
ThreadLimits | Namespace containing limits related to Discord threads. |
TokenRegex | Regex that can capture a Discord Token |
TriggerMetadataLimits | Namespace containing limits related to Discord Auto Moderation Trigger Metadata. |
TriggerTypeLimits | Namespace containing limits related to Discord Auto Moderation Triggers. |
TwemojiRegex | Regex that can capture a Twemoji (Twitter Emoji) |
UserLimits | Namespace containing limits related to Discord users and Direct Messages. |
UserOrMemberMentionRegex | Regex that can capture the ID of a user in Discord user mentions |
VoiceChannelLimits | Namespace containing limits related to Discord voice channels. |
WebhookRegex | Regex that captures the Webhook ID and token from a Discord Webhook URL. |
WebSocketUrlRegex | Regex that matches any WebSocket URL starting with ws or wss |
Functions
Function | Description |
---|---|
actionIsButtonOrMenu | Checks if a PaginatedMessageAction is a button or menu. |
actionIsLinkButton | Checks if a PaginatedMessageAction is a button with ButtonStyle.Link style `link`. |
canJoinVoiceChannel | Determines whether the client can join the given voice based channel. |
canReact | Determines whether or not we can send react to messages in a given channel. |
canReadMessages | Determines whether or not we can read messages in a given channel. |
canRemoveAllReactions | Determines whether or not we can remove reactions from messages in a given channel. |
canSendAttachments | Determines whether or not we can send attachments in a given channel. |
canSendEmbeds | Determines whether or not we can send embeds in a given channel. |
canSendMessages | Determines whether or not we can send messages in a given channel. |
createPartitionedMessageRow | Creates partitioned message rows based on the provided components. |
createTwemojiRegex | Creates a fresh instance of the Twemoji regex, which is useful if you don't want to worry about the effects of a global regex and the lastIndex |
isActionButton | Checks if the given action is a paginated message action button. |
isActionChannelMenu | Checks if the given action is a paginated message action channel menu. |
isActionLink | Checks if the given action is a paginated message action link. |
isActionMentionableMenu | Checks if the given action is a paginated message action mentionable menu. |
isActionRoleMenu | Checks if the given action is a paginated message action role menu. |
isActionStringMenu | Checks if the given action is a paginated message action string menu. |
isActionUserMenu | Checks if the given action is a paginated message action user menu. |
isAnyInteractableInteraction | Checks 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 |
isAnyInteraction | Checks 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 |
isButtonComponentBuilder | Checks if the given component is a button builder. |
isCategoryChannel | Checks whether a given channel is a CategoryChannel This checks for ChannelType.GuildCategory. |
isDMChannel | Checks whether a given channel is a DMChannel This checks for ChannelType.DM. |
isGroupChannel | Checks whether a given channel is a PartialGroupDMChannel This checks for ChannelType.GroupDM. |
isGuildBasedChannel | Checks if a channel comes from a guild. This checks that the channel is not ChannelType.DM. |
isGuildBasedChannelByGuildKey | Checks whether or not a channel comes from a guild. |
isGuildMember | Checks whether a given member is an instance of GuildMember, and not APIInteractionGuildMember, APIGuildMember, or Nullish |
isImageAttachment | Checks 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. |
isMediaAttachment | Checks 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. |
isMessageButtonInteractionData | Checks if the given interaction is a button interaction. |
isMessageChannelSelectInteractionData | Checks if the given interaction is a channel select interaction. |
isMessageInstance | Checks whether a given message is an instance of Message, and not APIMessage |
isMessageMentionableSelectInteractionData | Checks if the given interaction is a mentionable select interaction. |
isMessageRoleSelectInteractionData | Checks if the given interaction is a role select interaction. |
isMessageStringSelectInteractionData | Checks if the given interaction is a string select interaction. |
isMessageUserSelectInteractionData | Checks if the given interaction is a user select interaction. |
isNewsChannel | Checks whether a given channel is a NewsChannel. This checks for ChannelType.GuildAnnouncement. |
isNewsThreadChannel | Checks whether a given channel is an Announcement PublicThreadChannel This checks for ChannelType.AnnouncementThread. |
isNsfwChannel | Checks whether a given channel allows NSFW content or not |
isPrivateThreadChannel | Checks whether a given channel is a PrivateThreadChannel This checks for ChannelType.PrivateThread. |
isPublicThreadChannel | Checks whether a given channel is a PublicThreadChannel This checks for ChannelType.PublicThread. |
isStageChannel | Checks whether a given channel is a StageChannel This checks for ChannelType.GuildStageVoice. |
isTextBasedChannel | Checks whether a given channel is a TextBasedChannelTypes. This means it has a send method. |
isTextChannel | Checks whether a given channel is a TextChannel. This checks for ChannelType.GuildText. |
isThreadChannel | Checks whether a given channel is a ThreadChannel This checks for ChannelTypes.isThread(). |
isVoiceBasedChannel | Checks whether a given channel is a VoiceBasedChannel. This checks for Channel.isVoiceBased(). |
isVoiceChannel | Checks whether a given channel is a VoiceChannel This checks for ChannelType.GuildVoice. |
safelyReplyToInteraction | Safely replies to a message or interaction. This is primarily to save duplicated code in the main PaginatedMessage class |