From bff59d34247ca295ac9316e271427b372ad66da4 Mon Sep 17 00:00:00 2001 From: reality Date: Wed, 5 Jun 2013 18:13:39 +0000 Subject: [PATCH] channels in function loop --- modules/kick/commands.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/kick/commands.js b/modules/kick/commands.js index 0707a2d..fc7fe1b 100644 --- a/modules/kick/commands.js +++ b/modules/kick/commands.js @@ -47,13 +47,18 @@ var commands = function(dbot) { reason = event.input[2], channels = dbot.config.servers[server].channels; - _.each(channels, function(channel) { - setTimeout(function(channel) { - this.api.ban(server, banee, channel); - this.api.kick(server, banee, channel, reason + - ' (network-wide ban requested by ' + banner + ')'); - }.bind(this), 1000); - }, this); + var i = 0; + var banChannel = function(channels) { + if(i >= channels.length) return; + var channel = channels[i]; + this.api.ban(server, banee, channel); + this.api.kick(server, banee, channel, reason + + ' (network-wide ban requested by ' + banner + ')'); + setTimeout(function(channels) { + i++; banChannel(channels); + }, 1000); + } + banChannel(channels); var notifyString = dbot.t('nbanned', { 'banner': banner,