izy521/discord.io

bot exits without any error or warning

tonine1337 opened this issue · 4 comments

Hi,

The bot doesn't run when I type the command node bot.js. I've already done npm install woor/discord.io#gateway_v6 --save as explained in other issues but it doesn't help.

package.json

{
  "name": "bot-name",
  "version": "1.0.0",
  "description": "My First Discord Bot",
  "main": "bot.js",
  "author": "",
  "dependencies": {
    "discord.io": "github:woor/discord.io#gateway_v6",
    "winston": "^3.0.0"
  }
}

bot.js


var Discord = require('discord.io');
var bot = new Discord.Client({
  token: '',
  autorun: true
});

bot.on('ready', function() {
  console.log('Logged in as %s - %s\n', bot.username, bot.id);
});

bot.on('message', function(user, userID, channelID, message, event) {
  if (message === 'ping') {
    bot.sendMessage({
      to: channelID,
      message: 'pong'
    });
  }
});

it doesn't run because you don't have a bot token. go get your at https://discordapp.com/developers/applications/

I have the token I just removed it from here. Its added in the original file.

What happens? Do you see any error messages in the console? Is there no output? Does it hang forever?

Try adding a disconnect listener with bot.on("disconnect", console.log); for additional output, it will probably help!

You could also join the discord.io server for real-time help.

@cloudrac3r Thanks for the help
It was some other issue. Fixed and working.