-
-
Save LapisOnTheMoon/dbc40c3a15f9a7192daa9bec283d1126 to your computer and use it in GitHub Desktop.
Various regex for Discord
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
mentions: { | |
userOrMember: /^(?:<@!?)?(\d{17,19})>?$/, | |
channel: /^(?:<#)?(\d{17,19})>?$/, | |
role: /^(?:<@&)?(\d{17,19})>?$/, | |
snowflake: /^(\d{17,19})$/, | |
}, | |
misc: { | |
emoji: /^(?:<a?:\w{2,32}:)?(\d{17,19})>?$/, | |
username: /.{2,32}/, | |
invite: /(http(s)?:\/\/)?(www\.)?(discord\.(gg|li|me|io)|discordapp\.com\/invite|invite\.gg)\/.\w+/, | |
discriminator: /(#)\d{4}/, | |
tag: /.{2,32}(#)\d{4}/, | |
token: /[\w]{24}\.[\w]{6}\.[\w-_]{27}/, | |
}, | |
}; | |
/** | |
You can find the details how these regex works on https://regex101.com/ | |
If you have issues with these and if you know better way to do it please drop a comment :D | |
**/ |
Thanks mate, i'll help me with some of my projects.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this can benefit by including a regex for what discord itself considers a link (what makes it decide to convert a string to a hyperlink)