handle empty client queries

This commit is contained in:
realies 2017-10-31 19:46:58 +00:00 committed by Jérémie Astori
parent 15e9ea5001
commit c5de1b3dbe
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8

View File

@ -7,11 +7,15 @@ var Msg = require("../../models/msg");
exports.commands = ["query"]; exports.commands = ["query"];
exports.input = function(network, chan, cmd, args) { exports.input = function(network, chan, cmd, args) {
if (args.length === 0) { var target = args[0];
if (args.length === 0 || target.length === 0) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: "You cannot open a query window without an argument.",
}));
return; return;
} }
var target = args[0];
var query = _.find(network.channels, {name: target}); var query = _.find(network.channels, {name: target});
if (typeof query !== "undefined") { if (typeof query !== "undefined") {
return; return;