2019-02-24 23:03:53 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const Twitter = require('twitter-lite');
|
|
|
|
const rand = require('../../rand.js');
|
2019-02-25 18:42:22 +01:00
|
|
|
const Filter = require('bad-words');
|
2019-03-30 15:19:29 +01:00
|
|
|
const { MessageEmbed } = require('discord.js');
|
2019-02-25 18:42:22 +01:00
|
|
|
let filter = new Filter();
|
2019-02-25 03:18:04 +01:00
|
|
|
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret, twiChannel } = require('../../config.json');
|
2019-02-25 03:26:06 +01:00
|
|
|
const reload = require('auto-reload');
|
2019-02-24 23:03:53 +01:00
|
|
|
|
|
|
|
class tweetCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('tweet', {
|
|
|
|
aliases: ['tweet'],
|
|
|
|
category: 'general',
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'text',
|
|
|
|
type: 'string',
|
2019-06-23 03:41:59 +02:00
|
|
|
prompt: {
|
|
|
|
start: 'Write something to tweet',
|
|
|
|
},
|
2019-02-24 23:03:53 +01:00
|
|
|
match: 'rest'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
description: {
|
|
|
|
content: 'Send tweet from Haha yes twitter account',
|
|
|
|
usage: '[text]',
|
|
|
|
examples: ['this epic tweet is in my epic twitter']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
2019-02-28 17:35:53 +01:00
|
|
|
let censor = reload('../../json/censor.json');
|
|
|
|
let uncensor = reload('../../json/uncensor.json');
|
2019-02-26 15:28:08 +01:00
|
|
|
filter.addWords(...censor);
|
|
|
|
filter.removeWords(...uncensor);
|
2019-02-26 00:23:12 +01:00
|
|
|
|
2019-03-10 01:29:54 +01:00
|
|
|
const blacklist = reload('../../json/twiBlacklist.json');
|
2019-02-25 03:18:04 +01:00
|
|
|
const channel = this.client.channels.get(twiChannel);
|
|
|
|
|
|
|
|
if (blacklist.includes(message.author.id)) {
|
|
|
|
return message.channel.send('You have been blacklisted from this command... be less naughty next time.');
|
|
|
|
}
|
|
|
|
|
2019-02-24 23:03:53 +01:00
|
|
|
let text = args.text;
|
|
|
|
if (!text)
|
|
|
|
return;
|
|
|
|
|
2019-02-25 04:27:38 +01:00
|
|
|
//Filter out swear word
|
|
|
|
text = filter.clean(text);
|
2019-02-24 23:41:37 +01:00
|
|
|
|
2019-02-24 23:03:53 +01:00
|
|
|
text = rand.random(text, message);
|
|
|
|
|
|
|
|
try {
|
2019-02-25 03:18:04 +01:00
|
|
|
let client = new Twitter({
|
|
|
|
consumer_key: twiConsumer,
|
|
|
|
consumer_secret: twiConsumerSecret,
|
|
|
|
access_token_key: twiToken,
|
|
|
|
access_token_secret: twiTokenSecret
|
|
|
|
});
|
|
|
|
|
2019-02-24 23:03:53 +01:00
|
|
|
const response = await client.post('statuses/update', {
|
|
|
|
status: text
|
|
|
|
});
|
|
|
|
|
|
|
|
const tweetid = response.id_str;
|
|
|
|
|
2019-03-30 15:19:29 +01:00
|
|
|
const Embed = new MessageEmbed()
|
|
|
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
|
|
|
.setDescription(args.text)
|
|
|
|
.addField('Link', `https://twitter.com/HahaYesDB/status/${tweetid}`)
|
|
|
|
.setFooter(`Tweet ID: ${tweetid} | Author ID: ${message.author.id}`)
|
|
|
|
.setTimestamp();
|
2019-02-25 03:18:04 +01:00
|
|
|
|
2019-03-30 15:19:29 +01:00
|
|
|
channel.send({embed: Embed});
|
2019-02-25 03:18:04 +01:00
|
|
|
|
2019-02-24 23:03:53 +01:00
|
|
|
return message.channel.send(`Go see ur epic tweet https://twitter.com/HahaYesDB/status/${tweetid}`);
|
|
|
|
} catch(err) {
|
2019-02-24 23:41:37 +01:00
|
|
|
console.error(err);
|
2019-02-24 23:03:53 +01:00
|
|
|
return message.channel.send('Oh no, an error has occured :(');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = tweetCommand;
|