small update to the bot

This commit is contained in:
hydrabolt
2015-08-14 20:38:09 +01:00
parent 35c38bf2bb
commit dc86086e72

View File

@@ -86,9 +86,9 @@ Commands[ "clear" ] = {
var deletedCount = 0, var deletedCount = 0,
failedCount = 0, failedCount = 0,
todo = logs.length(); todo = logs.length();
for ( message of logs.contents ) { for ( msg of logs.contents ) {
if ( message.author.equals( bot.user ) ) { if ( msg.author.equals( bot.user ) ) {
bot.deleteMessage( message, function( err ) { bot.deleteMessage( msg, function( err ) {
todo--; todo--;
if ( err ) if ( err )
failedCount++; failedCount++;
@@ -97,7 +97,7 @@ Commands[ "clear" ] = {
if ( todo === 0 ) { if ( todo === 0 ) {
bot.reply( bot.reply(
message, msg,
"Done! " + deletedCount + " message(s) were deleted, with " + failedCount + " error(s).", "Done! " + deletedCount + " message(s) were deleted, with " + failedCount + " error(s).",
false, false,
true, { true, {
@@ -209,6 +209,51 @@ Commands[ "remind" ] = {
} }
} }
Commands[ "activity" ] = {
oplevel: 0,
fn: function( bot, params, message ) {
var amount = getKey(params, "amount") || getKey(params, "n") || 250;
var limit = getKey(params, "limit") || getKey(params, "l") || 10;
bot.getChannelLogs(message.channel, amount, function(err, logs){
if(err){
bot.reply(message, "error gettings logs.");
}else{
var activity = {}, count = 0;
for(msg of logs.contents){
count = logs.length();
if(!activity[msg.author.id])
activity[msg.author.id] = 0;
activity[msg.author.id]++;
}
var report = "here's a list of activity over the last "+count+" messages :\n\n";
var users = {};
for(id in activity){
users[id] = message.channel.server.members.filter("id", id, true);
}
activity = Object.keys(activity).sort(function(a,b){return activity[a]-activity[b]});
for(id in activity){
report += id + " | "+activity[id]+" | **"+ Math.round( (activity[id] / count) * 100 ) +"%**.\n";
}
bot.reply(message, report, false, false);
}
});
}
}
exports.Commands = Commands; exports.Commands = Commands;
function hasFlag( array, flag ) { function hasFlag( array, flag ) {