Skip to main content

Module: discord-utilities/src

Variables

ApplicationCommandLimits

Const ApplicationCommandLimits: Object

Namespace containing limits related to Discord application commands (slash commands).

Type declaration

NameTypeDescription
MaximumDescriptionCharacters100Maximum characters allowed in an application command description.
MaximumNameCharacters32Maximum characters allowed in an application command name.
MaximumOptionsLength25Maximum options allowed in an application command.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:129


ApplicationCommandOptionLimits

Const ApplicationCommandOptionLimits: Object

Namespace containing limits related to Choices of Discord Application Commands.

Type declaration

NameTypeDescription
MaximumChoicesLength25Maximum length of choices allowed in the option of an application command.
MaximumDescriptionCharacters100Maximum characters allowed in the description of an option of an application command.
MaximumNameCharacters32Maximum characters allowed in the name of an option of an application command.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:149


AutoCompleteLimits

Const AutoCompleteLimits: Object

Namespace container limits related to Discord autocomplete interactions.

Type declaration

NameTypeDescription
MaximumAmountOfOptions20Maximum options allowed in a single autocomplete response.
MaximumLengthOfNameOfOption100Maximum characters allowed in a select menu option's name.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:302


ButtonLimits

Const ButtonLimits: Object

Namespace containing limits related to Message Buttons.

Type declaration

NameTypeDescription
MaximumCustomIdCharacters100Maximum characters allowed in a button custom ID.
MaximumLabelCharacters80Maximum characters allowed in a button label.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:169


ChannelLimits

Const ChannelLimits: Object

Namespace containing limits related to Discord channels.

Type declaration

NameTypeDescription
MaximumDescriptionLength1024Maximum characters allowed in a channel description.
MaximumNameLength100Maximum characters allowed in a channel name.
MaximumViewersPerScreenShare50Maximum viewers allowed per screen share.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:4


ChannelMentionRegex

Const ChannelMentionRegex: RegExp

Regex that can capture the ID in Discord Channel mentions

raw /^<#(?<id>\d{17,19})>$/

remark Capture group 1 is the ID of the channel. It is named id.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:8


ChannelMessageRegex

Const ChannelMessageRegex: RegExp

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

raw /^(?<channelId>\d{17,19})-(?<messageId>\d{17,19})$/

remark Capture group 1 is the ID of the channel, named channelId.

remark Capture group 2 is the ID of the message, named messageId.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:17


DiscordHostnameRegex

Const DiscordHostnameRegex: RegExp

Regex that matches links on the known Discord host names

raw /(?<subdomain>\w+)\.?(?<hostname>dis(?:cord)?(?:app|merch|status)?)\.(?<tld>com|g(?:d|g|ift)|(?:de(?:sign|v))|media|new|store|net)/i

remark The regex is case insensitive

remark Capture group 1 is the subdomain for this URL. It is named subdomain.

remark Capture group 2 is the hostname for this URL, primarily discord but can also be discordmerch, discordstatus, dis, and discordapp. It is named hostname.

remark Capture group 3 is the Top-Level Domain without .. It is named tld.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:27


DiscordInviteLinkRegex

Const DiscordInviteLinkRegex: RegExp

Regex that can can capture the code of Discord invite links

raw /^(?:https?:\/\/)?(?:www\.)?(?:discord\.gg\/|discord(?:app)?\.com\/invite\/)?(?<code>[\w\d-]{2,})$/i

remark Capture group 1 is the invite URL's unique code. It is named code.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:35


EmbedLimits

Const EmbedLimits: Object

Namespace containing limits related to Discord embeds.

Type declaration

NameTypeDescription
MaximumAuthorNameLength256Maximum characters allowed in the author field of an embed.
MaximumDescriptionLength4096Maximum characters allowed in an embed description.
MaximumFieldNameLength256Maximum characters allowed in the name of a field in an embed.
MaximumFieldValueLength1024Maximum characters allowed in the avlue of a field in an embed.
MaximumFields25Maximum fields allowed in an embed.
MaximumFooterLength2048Maximum characters allowed in a footer of an embed.
MaximumTitleLength256Maximum characters allowed in the title of an embed.
MaximumTotalCharacters6000Maximum characters allowed in an embed, in total.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:24


EmojiLimits

Const EmojiLimits: Object

Namespace containing limits related to Discord emojis.

Type declaration

NameTypeDescription
MaximumEmojiNameLength32Maximum characters allowed in a custom guild emoji.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:69


EmojiRegex

Const EmojiRegex: RegExp

Regex that can capture the ID of any animated or non-animated custom Discord emoji

raw /^(?:<(?<animated>a)?:(?<name>\w{2,32}):)?(?<id>\d{17,21})>?$/

remark Capture group 1 can be used to determine whether the emoji is animated or not. It is named animated.

remark Capture group 2 is the name of the emoji as it is typed in a message. It is named name.

remark Capture group 3 is the ID of the emoji. It is named id.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:44


FormattedCustomEmoji

Const FormattedCustomEmoji: RegExp

Regex that matches any animated or non-animated custom Discord emoji. Unlike EmojiRegex It can be a substring of a larger string.

raw /<a?:\w{2,32}:\d{17,18}>/

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:51


FormattedCustomEmojiWithGroups

Const FormattedCustomEmojiWithGroups: RegExp

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.

raw /(?<animated>a?):(?<name>[^:]+):(?<id>\d{17,19})/

remark Capture group 1 can be used to determine whether the emoji is animated or not. It is named animated.

remark Capture group 2 is the name of the emoji as it is typed in a message. It is named name.

remark Capture group 3 is the ID of the emoji. It is named id.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:61


GuildLimits

Const GuildLimits: Object

Namespace containing limits related to Discord guilds.

Type declaration

NameTypeDescription
MaximumChannels500Maximum channels allowed per guild, including category channels.
MaximumRoles250Maximum roles allowed in a guild.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:79


GuildMemberLimits

Const GuildMemberLimits: Object

Namespace containing limits related to Discord guild members.

Type declaration

NameTypeDescription
MaximumDisplayNameLength32Maximum characters allowed in the display name of a guild member.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:94


HttpUrlRegex

Const HttpUrlRegex: RegExp

Regex that matches any URL starting with http or https

raw /^https?:\/\//

remark for WebSocket URLs see {@link WebsocketGenericUrlRegex}

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:68


InteractionLimits

Const InteractionLimits: Object

Namespace containing limits related to Discord interactions.

Type declaration

NameTypeDescription
MaximumButtonsPerActionRow5Maximum buttons allowed in a single action row.
MaximumOptionsInSelectMenus25Maximum options allowed in a single select menu.
MaximumSelectMenusPerActionRow1Maximum select menus allowed in a single action row.
MaximumTextInputsPerActionRow1Maximum text inputs allowed in a single action row.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:104


MessageLimits

Const MessageLimits: Object

Namespace containing limits related to Discord messages.

Type declaration

NameTypeDescription
MaximumActionRows5Maximum action rows allowed in a single message.
MaximumEmbeds10Maximum embeds allowed in a single message.
MaximumLength2000Maximum characters allowed in a single message for a user.
MaximumNitroLength4000Maximum characters allowed in a single message for a nitro user.
MaximumNitroUploadSize100000000Maximum upload size for a nitro user, in any guild or in DMs. Size is in bytes, and correspond to 10MB.
MaximumReactions20Maximum numbers of reactions allowed for a message.
MaximumUploadSize8000000Maximum upload size for a free user in a guild of tier 1 or below, or in DMs. Size is in bytes, and correspond to 8MB.
MaximumUploadSizeInGuildreadonly [8000000, 8000000, 50000000, 100000000]Maximum upload size for a free user for all different boost levels available in a guild. Sizes are in bytes, and correspond to 8MB, 8MB, 50MB, and 100MB.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:219


MessageLinkRegex

Const MessageLinkRegex: RegExp

Regex that can capture the Guild, Channel, and Message ID based on a shareable Discord message link.

raw /^(?:https:\/\/)?(?:ptb\.|canary\.)?discord(?:app)?\.com\/channels\/(?<guildId>(?:\d{17,19}|@me))\/(?<channelId>\d{17,19})\/(?<messageId>\d{17,19})$/

remark Capture group 1 is the ID of the guild the message was sent in. It is named guildId.

remark Capture group 2 is the ID of the channel in that guild the message was sent in. It is named channelId.

remark Capture group 3 is the ID of the message itself. It is named messageId.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:77


ModalLimits

Const ModalLimits: Object

Namespace containing limits related to Discord Modals.

Type declaration

NameTypeDescription
MaximumComponents5Maximum components allowed in a modal.
MaximumCustomIdCharacters100Maximum characters allowed in a modal custom ID.
MaximumTitleCharacters45Maximum characters allowed in a modal title.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:317


ModerationLimits

Const ModerationLimits: Object

Namespace containing limits related to built-in moderation features.

Type declaration

NameTypeDescription
MaximumTimeoutDuration2419200Maximum duration of a guild timeout, in seconds (corresponds to 28 days).

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:267


ParsedCustomEmoji

Const ParsedCustomEmoji: RegExp

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.

raw /a?:\w{2,32}:\d{17,18}/

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:86


ParsedCustomEmojiWithGroups

Const ParsedCustomEmojiWithGroups: RegExp

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.

raw /(?<animated>a?):(?<name>[^:]+):(?<id>\d{17,19})/

remark Capture group 1 can be used to determine whether the emoji is animated or not. It is named animated.

remark Capture group 2 is the name of the emoji as it is typed in a message. It is named name.

remark Capture group 3 is the ID of the emoji. It is named id.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:97


RoleLimits

Const RoleLimits: Object

Namespace containing limits related to Discord roles.

Type declaration

NameTypeDescription
MaximumNameLength100Maximum characters allowed in a role name.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:277


RoleMentionRegex

Const RoleMentionRegex: RegExp

Regex that can capture the ID in Discord Role mentions

raw /^<@&(?<id>\d{17,19})>$/

remark Capture group 1 is the ID of the role. It is named id.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:104


SelectMenuLimits

Const SelectMenuLimits: Object

Namespace containing limits related to Select Menus.

Type declaration

NameTypeDescription
MaximumCustomIdCharacters100Maximum characters allowed in a select menu custom ID.
MaximumLengthOfNameOfOption100Maximum characters allowed in a select menu option's name.
MaximumMaxValuesSize25Maximum "maximum" values allowed in a select menu.
MaximumMinValuesSize25Maximum "minimum" values allowed in a select menu.
MaximumOptionsLength25Maximum amount of options allowed in a select menu.
MaximumPlaceholderCharacters100Maximum characters allowed in a select menu placeholder.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:184


SnowflakeRegex

Const SnowflakeRegex: RegExp

Regex that can capture any Discord Snowflake ID

raw /^(?<id>\d{17,19})$/

remark Capture group 1 is the Snowflake. It is named id.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:111


TextInputLimits

Const TextInputLimits: Object

Namespace containing limits related to Discord Modal Text Input component.

Type declaration

NameTypeDescription
MaximumCustomIdCharacters100Maximum characters allowed in a text input custom ID.
MaximumLabelCharacters45Maximum characters allowed in a text input label.
MaximumPlaceholderCharacters100Maximum characters allowed in a text input placeholder.
MaximumValueCharacters4000Maximum characters allowed in a text input value.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:337


TokenRegex

Const TokenRegex: RegExp

Regex that can capture a Discord Token

raw /(?<mfaToken>mfa\.[a-z0-9_-]{20,})|(?<basicToken>[a-z0-9_-]{23,28}\.[a-z0-9_-]{6,7}\.[a-z0-9_-]{27})/i

remark Capture group 1 can be used to retrieve a token for a User that has Multi-Factor Authentication enabled. It is named mfaToken.

remark Capture group 2 can be used to retrieve a token for a User that doesn't have Multi-Factor Authentication enabled, or a Bot application. It is named basicToken.

remark For a valid token, either Capture group 1 or Capture group 2 will always be undefined, whereas the other group will then be defined and contain the matched token. You can use the name of the capture group to determine if the validated token was configured for a user with Multi-Factor Authentication, for a user without Multi-Factor Authentication, or for a bot application. If both capture groups are undefined, then the token is invalid.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:123


TwemojiRegex

Const TwemojiRegex: RegExp = twemojiRegex

Regex that can capture a Twemoji (Twitter Emoji)

raw See official source code

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:129


UserLimits

Const UserLimits: Object

Namespace containing limits related to Discord users and Direct Messages.

Type declaration

NameTypeDescription
MaximumBiographyLength190Maximum characters allowed in a user's biography (the "About Me" section).
MaximumUsersPerDMGroup10Maximum numbers of users in a DM group.

Defined in

projects/utilities/packages/discord-utilities/src/lib/limits.ts:287


UserOrMemberMentionRegex

Const UserOrMemberMentionRegex: RegExp

Regex that can capture the ID of a user in Discord user mentions

raw /^<@!?(?<id>\d{17,19})>$/

remark Capture group 1 is the ID of the user. It is named id.

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:136


WebSocketUrlRegex

Const WebSocketUrlRegex: RegExp

Regex that matches any WebSocket URL starting with ws or wss

raw /^wss?:\/\//

remark for regular HTTP URLs see HttpUrlRegex

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:143


WebhookRegex

Const WebhookRegex: RegExp

Regex that captures the Webhook ID and token from a Discord Webhook URL.

raw /(?<url>^https:\/\/(?:(?:canary|ptb).)?discordapp.com\/api\/webhooks\/(?<id>\d+)\/(?<token>[\w-]+)\/?$)/

remark Capture group 1 is the full URL of the Discord Webhook. It is named url.

remark Capture group 2 is the ID of the Discord Webhook. It is named id.

remark Capture group 3 is the token of the Discord Webhook. It is named token.

remark for regular HTTP URLs see HttpUrlRegex

Defined in

projects/utilities/packages/discord-utilities/src/lib/regexes.ts:153