Tweet API Discord.js

问题描述 投票:0回答:1
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"
}

您好,我遇到了错误,并且我试图通过不和谐鸣叫,以便我和我的朋友可以使用同一个帐户来取乐。请帮助我,我是初学者,不知道问题出在哪里...

javascript twitter discord.js
1个回答
0
投票

问题可能出在第16行和第17行,在这些情况下,更宽松的“ ==”条件可能优于更严格的“ ===”。

You can read more here.

希望有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.