fixing some whitespacing, and fixing the member count code

This commit is contained in:
Matt Burchett 2017-03-23 03:39:28 -05:00
parent e37e3feb39
commit 3f66a03d3f

34
bot.js
View File

@ -1,7 +1,7 @@
// Require Discord Libraries // Require Discord Libraries
var Discordie = require('discordie'); var Discordie = require('discordie');
// Require log4js for logging to files // Require log4js for logging to files
var log4js = require('log4js'); var log4js = require('log4js');
// require custom settings // require custom settings
@ -35,21 +35,23 @@ client.connect({
client.Dispatcher.on(Events.GATEWAY_READY, e => { client.Dispatcher.on(Events.GATEWAY_READY, e => {
// acknoledge connection to console logs // acknoledge connection to console logs
logcon.info('Connected as: ' + client.User.username); logcon.info('Connected as: ' + client.User.username);
// check for the number of active users every 30 seconds and log to the active users logs });
setInterval(function() {
// check for the number of active users every 30 seconds and log to the active users logs
setInterval(function() {
client.Users.fetchMembers(config.guild_id); client.Users.fetchMembers(config.guild_id);
actcon.info(config.guild_name + " Active Users: " + client.Users.onlineMembersForGuild(config.guild_id).length);}, 30000) actcon.info(config.guild_name + " Active Users: " + client.Users.onlineMembersForGuild(config.guild_id).length);}, 30000);
});
// when messages are created // when messages are created
client.Dispatcher.on(Events.MESSAGE_CREATE, e => { client.Dispatcher.on(Events.MESSAGE_CREATE, e => {
// log the guild name, the channel name, the username, and the message to the channels log // log the guild name, the channel name, the username, and the message to the channels log and disable DMs.
if (!e.message.isPrivate)
chancon.info(e.message.guild.name + ":" + " #" + e.message.channel.name + ": " + "<" + e.message.displayUsername + ">: "+ e.message.content); chancon.info(e.message.guild.name + ":" + " #" + e.message.channel.name + ": " + "<" + e.message.displayUsername + ">: "+ e.message.content);
}); });
// if connection is lost to Discord, issue a reconnect. // if connection is lost to Discord, issue a reconnect.
client.Dispatcher.on(Events.DISCONNECTED, e => { client.Dispatcher.on(Events.DISCONNECTED, e => {
// force disconnection to Discord // force disconnection to Discord
client.disconnect(); client.disconnect();
logcon.info('Disconnected from server ...'); logcon.info('Disconnected from server ...');
@ -59,14 +61,14 @@ client.Dispatcher.on(Events.DISCONNECTED, e => {
client.connect({ client.connect({
token: config.bot_token token: config.bot_token
}); });
}); });
// also, reconnect the bot hourly. // also, reconnect the bot hourly.
setInterval(function() { setInterval(function() {
logcon.info('Reconnecting to server per timeout of ' + config.reconnect + 'ms.'); logcon.info('Reconnecting to server per timeout of ' + config.reconnect + 'ms.');
client.disconnect(); client.disconnect();
client.connect({ client.connect({
token: config.bot_token token: config.bot_token
}); });
}, config.reconnect); }, config.reconnect);