inital commit
This commit is contained in:
parent
3382292b54
commit
da2ebde8ab
32
bot.js
Normal file
32
bot.js
Normal 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
5
config.json.example
Normal 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
11
package.json
Normal 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"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user