Skip to content

Instantly share code, notes, and snippets.

@anishshobithps
Last active July 21, 2022 13:28
Show Gist options
  • Save anishshobithps/10cfa62b2defd396d87ff4c50be897f8 to your computer and use it in GitHub Desktop.
Save anishshobithps/10cfa62b2defd396d87ff4c50be897f8 to your computer and use it in GitHub Desktop.
Some awesome regex to make your coding easier :P
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
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment