Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138221

Tweet API Discord.js

$
0
0
const Discord = require('discord.js');
const Commando = require('discord.js-commando');
const Twitter = require('twitter');
const config = require("../config.json");

const clientTwitter = new Twitter({
    consumer_key: config.twitterConsumerKey,
    consumer_secret: config.twitterConsumerSecret,
    access_token_key: config.twitterAccessKey,
    access_token_secret: config.twitterAccessSecret
});

module.exports.run = async(client, message, args) => {
    try {
        // Checks the guild and only allows commands from trusted guild. Define in config.json
        if(message.guild.id === config.myGuildID) { 
            if(args === undefined){
                message.channel.send("You must write something :thinking:");
            } else {
                var argR = args;
                clientTwitter.post('statuses/update', {status: argR},  function(error, tweet, response) {
                    if (!error) {
                        message.channel.send("Tweeted :notes:");
                      } else {
                        message.channel.send(":x: Error");
                      }
                });
            }
        } else{
            message.channel.send("Command not allowed in this guild :angry:");
        }
    } catch(e) {
        console.log(e);
    }
}



module.exports.help = {
    name: "tweet"
}

Hello I am getting errors and im trying to tweet via discord so me and my friends could use a same account for fun.Help me please ,I am a beginner and I don't know where the problem is...


Viewing all articles
Browse latest Browse all 138221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>