Commit 1bbc7743 authored by Loïc Bersier's avatar Loïc Bersier 😎
Browse files

Better link detection


Signed-off-by: Loïc Bersier's avatarloicbersier <loic.bersier1@gmail.com>
parent 5612abd8
......@@ -33,7 +33,7 @@ class tweetCommand extends Command {
async exec(message, args) {
if (args.text) {
// Very simple link detection
if (args.text.includes('http') && !args.text.includes('twitter.com')) return message.channel.send('You may not tweet links outside of twitter.com');
if (new RegExp('([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?').test(args.text) && !args.text.includes('twitter.com')) return message.channel.send('You may not tweet links outside of twitter.com');
// Do not allow discord invites
if (args.text.includes('discord.gg') || args.text.includes('discord.com/invite/')) return message.channel.send('No discord invite allowed.');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment