discord-markdown-parser
Version:
Parse discord-style markdown into an abstract syntax tree.
119 lines (118 loc) • 3.16 kB
TypeScript
/**
* Matches Discord channel mentions.
* @example <#123456789012345678>
*
* The regex captures a 17-20 digit channel ID inside <#...> brackets.
*/
export declare const ChannelMentionRegex: RegExp;
/**
* Matches custom emoji mentions.
* @example <:smile:12345678901234567>
*
* The regex captures:
* - Optional "a" for animated emojis
* - Emoji name (2-32 characters)
* - Emoji ID (17-21 digits)
*/
export declare const EmojiRegex: RegExp;
/**
* Matches Discord role mentions.
* @example <@&123456789012345678>
*
* The regex captures a 17-20 digit role ID inside <@&...> brackets.
*/
export declare const RoleMentionRegex: RegExp;
/**
* Matches Discord user mentions.
*
* @example <@123456789012345678> or <@!123456789012345678>
*
* The regex captures a 17-20 digit user ID, optionally preceded by "!".
*/
export declare const UserMentionRegex: RegExp;
/**
* Matches the @everyone mention.
*/
export declare const EveryoneRegex: RegExp;
/**
* Matches the @here mention.
*/
export declare const HereRegex: RegExp;
/**
* Matches block quotes in two formats:
* 1. Single line: ">>> text"
* 2. Multi-line: "> text\n> more text"
*
* @example >>> This is a block quote
*/
export declare const BlockQuoteRegex: RegExp;
/**
* Matches code blocks with optional language specification.
*
* @example ```javascript
* const example = "code";
* ```
*/
export declare const CodeBlockRegex: RegExp;
/**
* Matches the ¯\_(ツ)_/¯ emoticon.
*/
export declare const EmoticonRegex: RegExp;
/**
* Matches spoiler text wrapped in double pipes.
*
* @example ||This is a spoiler||
*/
export declare const SpoilerRegex: RegExp;
/**
* Matches strikethrough text wrapped in tildes.
*
* @example ~~This text is strikethrough~~
*/
export declare const StrikeThroughRegex: RegExp;
/**
* Matches plain text content in messages.
*
* This regex is designed to capture text up to certain delimiters
* like punctuation, newlines, or specific patterns.
*/
export declare const TextRegex: RegExp;
/**
* Matches Discord timestamp mentions.
*
* @example <t:123456> or <t:123456:t> for specific formats
*/
export declare const TimestampRegex: RegExp;
/**
* Matches markdown headings (H1-H3 level).
*
* @example # Heading
* @example ## Subheading
* @example ### Subsubheading
*/
export declare const HeadingRegex: RegExp;
/**
* Matches subtext in markdown headings.
*
* @example -# Subtext
*/
export declare const SubtextRegex: RegExp;
/**
* Matches for slash command mentions.
*
* @example </command:123456789012345678>
*
* Slash command names can be up to 32 characters long,
* and the regex for the name was taken from the discord api documentation
* Commands can also be nested up to 3 times (</command group subcommand:id>)
*/
export declare const SlashCommandRegex: RegExp;
/**
* Matches for guild navigation mentions.
* The `linked-roles` type adds in another opptional :ROLE-ID field.
*
* @example <12345679012345678:customize>
*
* @see {@link https://discord.com/developers/docs/reference#message-formatting-guild-navigation-types} for available types
*/
export declare const GuildNavigationRegex: RegExp;