mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 03:35:41 +01:00
Added Application stats, will output at midnight to the server and log.
This commit is contained in:
parent
bc22735a5c
commit
6b210b3270
5
app.js
5
app.js
@ -4,6 +4,11 @@ var Application = function() {
|
||||
this.logChannel = null;
|
||||
this.warnings = [];
|
||||
this.bans = [];
|
||||
this.stats = {
|
||||
joins: 0,
|
||||
leaves: 0,
|
||||
warnings: 0
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = new Application();
|
||||
|
@ -19,6 +19,7 @@ exports.command = function(message) {
|
||||
app.logChannel.sendMessage(`Error banning ${user} ${user.username}`);
|
||||
logger.error(`Error banning ${user.toString()} ${user} ${user.username}.`, error);
|
||||
});
|
||||
|
||||
data.flushBans();
|
||||
});
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ exports.command = function(message) {
|
||||
app.warnings.push(new UserWarning(user.id, user.username, message.author.id, message.author.username, count));
|
||||
data.flushWarnings();
|
||||
|
||||
app.stats.warnings += 1;
|
||||
|
||||
if (count + 1 >= 3) {
|
||||
app.logChannel.sendMessage(`.ban ${user}`);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
"discord.js": "^10.0.1",
|
||||
"ip": "^1.1.5",
|
||||
"logdna": "^1.2.3",
|
||||
"node-schedule": "^1.2.3",
|
||||
"request": "^2.79.0",
|
||||
"winston": "^2.3.0"
|
||||
}
|
||||
|
19
server.js
19
server.js
@ -29,6 +29,25 @@ client.on('ready', () => {
|
||||
logger.info('Bot is now online and connected to server.');
|
||||
});
|
||||
|
||||
client.on("guildMemberAdd", (member) => {
|
||||
app.stats.joins += 1;
|
||||
});
|
||||
|
||||
client.on("guildMemberRemove", (member) => {
|
||||
app.stats.leaves += 1;
|
||||
});
|
||||
|
||||
// Output the stats for app.stats every 24 hours.
|
||||
schedule.scheduleJob({ hour: 23, minute: 59 }, function(){
|
||||
logger.info(`Here are today's stats for ${(new Date()).toLocaleDateString()}! ${app.stats.joins} users have joined, ${app.stats.leaves} users have left, ${app.stats.warnings} warnings have been issued.`);
|
||||
app.logChannel.sendMessage(`Here are today's stats for ${(new Date()).toLocaleDateString()}! ${app.stats.joins} users have joined, ${app.stats.leaves} users have left, ${app.stats.warnings} warnings have been issued.`);
|
||||
|
||||
// Clear the stats for the day.
|
||||
app.stats.joins = 0;
|
||||
app.stats.leaves = 0;
|
||||
app.stats.warnings = 0;
|
||||
});
|
||||
|
||||
client.on('message', message => {
|
||||
if (message.author.bot && message.content.startsWith('.ban') == false) { return; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user