inital commit

This commit is contained in:
Matt Burchett 2017-03-22 01:23:52 -05:00
parent 3382292b54
commit da2ebde8ab
3 changed files with 48 additions and 0 deletions

32
bot.js Normal file
View File

@ -0,0 +1,32 @@
var Discordie = require('discordie'); // Requite Discord Libraries
var log4js = require('log4js'); // Require log4js for logging to files
var config = require('./config.json'); // require custom settings
// Configure log4js
log4js.configure({
appenders: [
{ type: 'console' },
{ type: 'file', filename: 'logs/console.log', category: 'console'},
{ type: 'file', filename: 'logs/activeusers.log', category: 'activeusers'},
{ type: 'file', filename: 'logs/channels.log', category: 'channels'}
]
});
const Events = Discordie.Events;
const client = new Discordie();
client.connect({
token: config.bot_token
});
client.Dispatcher.on(Events.GATEWAY_READY, e => {
var logcon = log4js.getLogger('console');
var actcon = log4js.getLogger('activeusers');
logcon.info('Connected as: ' + client.User.username);
setInterval(function() {actcon.info(config.guild_name + " Active Users: " + client.Users.onlineMembersForGuild(config.guild_id).length);}, 30000)
});
client.Dispatcher.on(Events.MESSAGE_CREATE, e => {
var chancon = log4js.getLogger('channels');
chancon.info(e.message.guild.name + ":" + " #" + e.message.channel.name + ": " + "<" + e.message.displayUsername + ">: "+ e.message.content);
});

5
config.json.example Normal file
View File

@ -0,0 +1,5 @@
{
"bot_token": "<Your discord bot token>",
"guild_id": "<Your Channel ID - Enable Developer Tools in Discord, right click on the server, copy id>",
"guild_name": "<This is just for the log files, I named mine the name of the server>"
}

11
package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "discord-stats-bot",
"version": "1.0.0",
"description": "Discord Stats Bot (for exporting into ELK or other centralized logging)",
"main": "bot.js",
"scripts": {
"bot": "nodemon bot.js"
},
"author": "Matt Burchett",
"license": "MIT"
}