From 5233fb2dbb9f4ecc962366d795554cc97df29def Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 3 Mar 2020 11:47:09 +0200 Subject: [PATCH] Fix sending unhandled numerics to target channel --- src/plugins/irc-events/unhandled.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/plugins/irc-events/unhandled.js b/src/plugins/irc-events/unhandled.js index 5d968425..4c976ba4 100644 --- a/src/plugins/irc-events/unhandled.js +++ b/src/plugins/irc-events/unhandled.js @@ -8,18 +8,19 @@ module.exports = function(irc, network) { irc.on("unknown command", function(command) { let target = network.channels[0]; - if (command.params.length > 0) { - // Do not display users own name - if (command.params[0] === network.irc.user.nick) { - command.params.shift(); - } else { - // If this numeric starts with a channel name that exists - // put this message in that channel - const channel = network.getChannel(command.params[0]); + // Do not display users own name + if (command.params.length > 0 && command.params[0] === network.irc.user.nick) { + command.params.shift(); + } - if (typeof channel !== "undefined") { - target = channel; - } + // Check the length again because we may shift the nick above + if (command.params.length > 0) { + // If this numeric starts with a channel name that exists + // put this message in that channel + const channel = network.getChannel(command.params[0]); + + if (typeof channel !== "undefined") { + target = channel; } }