Send tweet from discord!
This commit is contained in:
parent
bab84c7890
commit
b70ba6fb49
3 changed files with 57 additions and 57 deletions
56
commands/general/tweet.js
Normal file
56
commands/general/tweet.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
const Twitter = require('twitter-lite');
|
||||
const rand = require('../../rand.js');
|
||||
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret } = require('../../config.json');
|
||||
|
||||
class tweetCommand extends Command {
|
||||
constructor() {
|
||||
super('tweet', {
|
||||
aliases: ['tweet'],
|
||||
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 text = args.text;
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
text = rand.random(text, message);
|
||||
|
||||
let client = new Twitter({
|
||||
consumer_key: twiConsumer,
|
||||
consumer_secret: twiConsumerSecret,
|
||||
access_token_key: twiToken,
|
||||
access_token_secret: twiTokenSecret
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await client.post('statuses/update', {
|
||||
status: text
|
||||
});
|
||||
|
||||
const tweetid = response.id_str;
|
||||
|
||||
// Send the final text
|
||||
return message.channel.send(`Go see ur epic tweet https://twitter.com/HahaYesDB/status/${tweetid}`);
|
||||
} catch(err) {
|
||||
return message.channel.send('Oh no, an error has occured :(');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = tweetCommand;
|
|
@ -1,56 +0,0 @@
|
|||
//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;
|
|
@ -14,7 +14,7 @@
|
|||
"node-fetch": "^2.3.0",
|
||||
"reload-json": "^0.3.1",
|
||||
"superagent": "^4.1.0",
|
||||
"twitter": "^1.7.1",
|
||||
"twitter-lite": "^0.9.1",
|
||||
"youtube-dl": "^1.12.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in a new issue