Skip to main content

Variable: 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,20}|@me))/(?<channelId>\d{17,20})/(?<messageId>\d{17,20})$/

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.

Source

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