var Discord = require('discord.js');
var Settings = require('./settings.json');

var Help = require('./commands/help.js');
var Streams = require('./commands/streams.js');
var JSEval = require('./commands/jseval.js');

var cmds = {
  "help" : Help.handleHelp,
  "streams": Streams.handleStreams,
  "jseval": JSEval.handleJSEval,
};

var bot = new Discord.Client();

// save the RE as they're expensive to create
var cmd_re = new RegExp(`^${Settings.bot_cmd} (${Object.keys(cmds).join('|')})(.*) *`, 'i');

bot.on('message', function (message) {
  // don't respond to own messages
  if (bot.user.username == message.author.username)
    return;

  // check if message is a command
  var cmd_match = message.cleanContent.match(cmd_re);

  // not a known command
  if (!cmd_match)
    return;

  // process command
  var cmd = cmd_match[1];
  var cmd_args = cmd_match[2].trim();

  cmds[cmd](bot, message, cmd_args);
});

bot.loginWithToken(Settings.api_token);

@@ -367,16 +367,37 @@
 .Client(
+%7BautoReconnect: true%7D
 );%0D%0A%0D%0A//
@@ -965,24 +965,336 @@
 s);%0D%0A%7D);%0D%0A%0D%0A
+bot.on('disconnected', function () %7B%0D%0A  console.warn('Bot has been disconnected from server...')%0D%0A%7D)%0D%0A%0D%0Abot.on('error', function (e) %7B%0D%0A  console.error(%22error: %22, e)%0D%0A  console.error(e.trace)%0D%0A%7D)%0D%0A%0D%0Abot.on('ready', function () %7B%0D%0A  console.log('Connected to discord server')%0D%0A%7D)%0D%0A%0D%0Aconsole.log('Connecting...')%0D%0A
 bot.loginWit

add informational output for bot status