diff --git a/modules/report/report.js b/modules/report/report.js index 77100a7..4a6b09c 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -1,3 +1,5 @@ +var _ = require('underscore')._; + var report = function(dbot) { var commands = { '~report': function(event) { @@ -5,29 +7,21 @@ var report = function(dbot) { var nick = event.input[2]; var reason = event.input[3]; - if(event.allChannels.hasOwnProperty(channelName)) { + if(_.has(event.allChannels, channelName)) { var channel = event.allChannels[channelName]; - if(channel.nicks.hasOwnProperty(nick)) { - var ops = []; - for(var possibOps in channel.nicks) { - if(channel.nicks[possibOps].op == true) { - ops.push(possibOps); - } - } + if(_.has(channel.nicks, nick)) { + var ops = _.filter(channel.nicks, function(user) { + return user.op; + }); - // Does the channel have an admin channel? - if(event.allChannels.hasOwnProperty('#' + channelName)) { - ops.push('#' + channelName); - } - - for(var i=0;i