From bab84c789043efc3762eadd0186dabe0f7d87c80 Mon Sep 17 00:00:00 2001 From: Loic Bersier Date: Sun, 24 Feb 2019 15:47:19 +0100 Subject: [PATCH] Need to finish this command --- commands/general/twitter.js | 56 +++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 57 insertions(+) create mode 100755 commands/general/twitter.js diff --git a/commands/general/twitter.js b/commands/general/twitter.js new file mode 100755 index 0000000..5b57903 --- /dev/null +++ b/commands/general/twitter.js @@ -0,0 +1,56 @@ +//TODO +//FIX INDENT +//PUT TWITTER KEY ON CONFIG.JSON +//SEND FEEDBACK ONCE THE COMMAND HAVE BEEN EXECUTED +const { Command } = require('discord-akairo'); +const Twitter = require('twitter'); +const rand = require('../../rand.js'); + +class twitterCommand extends Command { + constructor() { + super('twitter', { + aliases: ['twitter'], + category: 'general', + 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) { + + let client = new Twitter({ + consumer_key: '', + consumer_secret: '', + access_token_key: '', + access_token_secret: '' + }); + + let text = args.text; + if (!text) + return; + + text = rand.random(text, message); + + client.post('statuses/update', {status: 'test'}, function(error, tweet, response) { + if (!error) { + console.log(tweet); + } + console.log(response); + }); + + // Send the final text + return message.channel.send('epic'); + } +} + +module.exports = twitterCommand; \ No newline at end of file diff --git a/package.json b/package.json index b741d94..005c45d 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "node-fetch": "^2.3.0", "reload-json": "^0.3.1", "superagent": "^4.1.0", + "twitter": "^1.7.1", "youtube-dl": "^1.12.2" }, "devDependencies": {