var Discord = require("discord.js");
var config = require("./config");

var mybot = new Discord.Client();
var myUser;
mybot.on("message", function(message) {
	if(message.content === "ping")
	{
		mybot.reply(message, "pong");
	}
	if(message.content === "!help")
	{
		var msg = "You need help " + message.author;
		var general = mybot.channels.get("name", "general");
//		var general = mybot.servers.random().defaultChannel;
//		mybot.sendMessage(message.channel, msg);
		mybot.sendMessage(general, msg);
	}
	if(message.content.toLowerCase().indexOf("hello") > -1 && message.isMentioned(myUser))
	{
		var msg =  "Hello " + message.author;
		mybot.sendMessage(message.channel, msg);
	}
});
mybot.on("ready", function()
{
	mybot.setPlayingGame("with your emotions");
	myUser = mybot.users.get("username", "DeixBot");
	for (var i = 0; i < mybot.servers.length; i++)
	{
		var server = mybot.servers[i];
		var msg = "S'up " + server.name + "!";
		mybot.sendMessage(server.defaultChannel, msg);
	}
});

process.on("SIGINT", function()
{
	for (var i = 0; i < mybot.servers.length; i++)
	{
		var server = mybot.servers[i];
		mybot.sendMessage(server.defaultChannel, "Peace out!", function(i){
			if(i + 1 == mybot.servers.length)
			{
				mybot.logout();
			}
		});
	}


//	var general = mybot.servers.get("name", "DeixCraft Test").defaultChannel;
//	mybot.sendMessage(general, "Peace out!", function()
//	{
//		mybot.logout();
//	});
});


mybot.loginWithToken(config.discord.key);

@@ -310,189 +310,40 @@
 ;%0A%09%09
-var general = mybot.channels.get(%22name%22, %22general%22);%0A//%09%09var general = mybot.servers.random().defaultChannel;%0A//%09%09mybot.sendMessage(message.channel, msg);%0A%09%09mybot.sendMessage(genera
+mybot.sendMessage(message.channe
 l, m
@@ -1107,174 +1107,8 @@
 %0A%09%7D%0A
-%0A%0A//%09var general = mybot.servers.get(%22name%22, %22DeixCraft Test%22).defaultChannel;%0A//%09mybot.sendMessage(general, %22Peace out!%22, function()%0A//%09%7B%0A//%09%09mybot.logout();%0A//%09%7D);%0A
 %7D);%0A

Tidy up of old code