为什么我的令牌没有启动我的不和谐机器人?

时间:2018-11-03 22:06:41

标签: javascript node.js

好的,有3个文件,可以说我的令牌是0000000000

每次我尝试在cmd.exe中执行“ node bot.js”时,它只会运行代码,但该bot不会联机或其他任何方式,并且仍然无响应。

我基本上一直在窃取https://www.digitaltrends.com/gaming/how-to-make-a-discord-bot/并以不和谐的方式提出问题,目前看来它已具备所需的一切,但它似乎仍无法使该机器人上线。有什么我想念的吗?我看过代码,没有发现任何乱码。它完全可以调用auth.json,但不会启动bot

bot.js

var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
    colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
   token: auth.token,
   autorun: true
});
bot.on('ready', function (evt) {
    logger.info('Connected');
    logger.info('Logged in as: ');
    logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
    // Our bot needs to know if it will execute a command
    // It will listen for messages that will start with `!`
    if (message.substring(0, 1) == '!') {
        var args = message.substring(1).split(' ');
        var cmd = args[0];

        args = args.splice(1);
        switch(cmd) {
            // !ping
            case 'ping':
                bot.sendMessage({
                    to: channelID,
                    message: 'Pong!'
                });
            break;
            // Just add any case commands if you want to..
         }
     }
});

auth.json

{
"token": "0000000000"
}

package.json

{
"name": "bot name",
"version": "1.0.0",
"description": "this bot",
"main": "bot.js",
"author": "my name",
"dependencies": {}
}

0 个答案:

没有答案