Do not allow links outside of twitter.com

This commit is contained in:
loicbersier 2020-07-16 09:25:03 +02:00
parent 7ed7b6c338
commit 507ed403e1

View file

@ -31,6 +31,13 @@ class tweetCommand extends Command {
} }
async exec(message, args) { 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');
// 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.');
}
let Attachment = (message.attachments).array(); let Attachment = (message.attachments).array();
if (!Attachment[0] && !args.text) return message.channel.send('You need to input something for me to tweet!'); if (!Attachment[0] && !args.text) return message.channel.send('You need to input something for me to tweet!');
@ -49,12 +56,7 @@ class tweetCommand extends Command {
// If account is younger than 6 months old don't accept attachment // If account is younger than 6 months old don't accept attachment
if (Attachment[0] && message.author.createdAt > date.setMonth(date.getMonth() - 6)) { if (Attachment[0] && message.author.createdAt > date.setMonth(date.getMonth() - 6)) {
return message.channel.send('Your account need to be 6 months or older to be able to send attachment!'); return message.channel.send('Your account need to be 6 months or older to be able to send attachment!');
} }
if (args.text)
if (args.text.includes('discord.gg') || args.text.includes('discord.com/invite/')) return message.channel.send('No discord invite allowed.');
const client = this.client; const client = this.client;