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

var client = new Discord.Client();
var botUser;


client.on("message", function(message) {
	if(message.content.toLowerCase().indexOf("hello") > -1 && message.isMentioned(botUser)) {
		var msg =  "Hello " + message.author;
		client.sendMessage(message.channel, 'Hello ' + message.author);
	}

	if(message.content.charAt(0) == config.cmdprefix) {
		switch(message.content.substring(1)){
			case 'ping':
				client.reply(message, "pong");
				break;
			case 'help':
				client.sendMessage(message.channel, "You need help " + message.author);
				break;
			case 'bh':
				playBennyHill(message.author.voiceChannel);
				break;
		}
	}
});

//Hilarity ensues
function playBennyHill(voiceChannel) {
	client.joinVoiceChannel(voiceChannel, function(error, voiceConnection){
		if(error) {
			return console.error(error);
		}
		voiceConnection.playFile("sound.mp3", function(error, intent) {
			if(error) {
				return console.error(error);
			}
			intent.on("error", function(error) {
				return console.error(error);
			});
			intent.once("end", function() {
				client.leaveVoiceChannel(voiceConnection);
			});
		});
	});
}

//Called once the bot is logged in and ready to use.
client.on("ready", function() {
	client.setPlayingGame("with your emotions");
	botUser = client.users.get("username", "DeixBot");
	for (var i = 0; i < client.servers.length; i++) {<commit_msg>Check for a voice channel before joining it<commit_after>var Discord = require("discord.js");
var config = require("./config");

var client = new Discord.Client();
var botUser;


client.on("message", function(message) {
	if(message.content.toLowerCase().indexOf("hello") > -1 && message.isMentioned(botUser)) {
		var msg =  "Hello " + message.author;
		client.sendMessage(message.channel, 'Hello ' + message.author);
	}

	if(message.content.charAt(0) == config.cmdprefix) {
		switch(message.content.substring(1)){
			case 'ping':
				client.reply(message, "pong");
				break;
			case 'help':
				client.sendMessage(message.channel, "You need help " + message.author);
				break;
			case 'bh':
				playBennyHill(message.author.voiceChannel);
				break;
		}
	}
});

//Hilarity ensues
function playBennyHill(voiceChannel) {
	if(voiceChannel != null) {
		client.joinVoiceChannel(voiceChannel, function(error, voiceConnection){
			if(error) {
				return console.error(error);
			}
			voiceConnection.playFile("sound.mp3", function(error, intent) {
				if(error) {
					return console.error(error);
				}
				intent.on("error", function(error) {
					return console.error(error);
				});
				intent.once("end", function() {
					client.leaveVoiceChannel(voiceConnection);
				});
			});
		});
	}
}

//Called once the bot is logged in and ready to use.
client.on("ready", function() {
	client.setPlayingGame("with your emotions");
	botUser = client.users.get("username", "DeixBot");
	for (var i = 0; i < client.servers.length; i++) {
{'fraction_non_alphanumeric': 0.1620168067226891, 'fraction_numerical': 0.0033613445378151263, 'mean_word_length': 4.1577123050259965, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '281542', 'n_tokens_mistral': 1097, 'n_tokens_neox': 962, 'n_words': 195}