From 4765f0694061f183a912a8f5605243fe8efa0539 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 3 Jul 2019 11:20:29 +0300 Subject: [PATCH] Make sure unhandled command has params --- src/plugins/irc-events/unhandled.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/irc-events/unhandled.js b/src/plugins/irc-events/unhandled.js index 1fb66270..3f78eb25 100644 --- a/src/plugins/irc-events/unhandled.js +++ b/src/plugins/irc-events/unhandled.js @@ -8,16 +8,18 @@ module.exports = function(irc, network) { irc.on("unknown command", function(command) { let target = network.channels[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]); + 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]); - if (typeof channel !== "undefined") { - target = channel; + if (typeof channel !== "undefined") { + target = channel; + } } }