izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 155 forks source link

bot exits without any error or warning #282

Closed tonine1337 closed 6 years ago

tonine1337 commented 6 years ago

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'
    });
  }
});
Mrthomas20121 commented 6 years ago

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

tonine1337 commented 6 years ago

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

cloudrac3r commented 6 years ago

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.

tonine1337 commented 6 years ago

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