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');
|
|
|
|
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',
|
2019-02-25 20:28:08 +01:00
|
|
|
cooldown: 86400000,
|
2019-02-25 19:45:40 +01:00
|
|
|
ratelimit: 3,
|
2019-02-24 23:03:53 +01:00
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'text',
|
|
|
|
type: 'string',
|
|
|
|
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-26 00:23:12 +01:00
|
|
|
let censor = reload('../../json/twitter/censor.json');
|
|
|
|
let uncensor = reload('../../json/twitter/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-02-25 03:26:06 +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;
|
|
|
|
|
|
|
|
// Send the final text
|
2019-02-25 03:18:04 +01:00
|
|
|
|
2019-02-27 15:34:55 +01:00
|
|
|
channel.send(`AUTHOR: ${message.author.username} (${message.author.id}) Sent: ${args.text}\nhttps://twitter.com/HahaYesDB/status/${tweetid}`);
|
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;
|