mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
small update to the bot
This commit is contained in:
@@ -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 ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user