From c6d33d8bba76f94f1444e51a9d0df2661cf5820d Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 8 Dec 2018 01:30:15 +0200 Subject: [PATCH] Make sure there are enough args before getting args --- commands.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index 7f53ce3..63bff75 100644 --- a/commands.go +++ b/commands.go @@ -134,13 +134,18 @@ func (handler *CommandHandler) CommandHelp(ce *CommandEvent) { }, "\n")) } -const cmdImportHelp = `import JID|contacts - Open up a room for JID or for each WhatsApp contact` +const cmdImportHelp = `import |contacts - Open up a room for JID or for each WhatsApp contact` // CommandImport handles import command func (handler *CommandHandler) CommandImport(ce *CommandEvent) { // ensure all messages go to the management room ce.RoomID = ce.User.ManagementRoom + if len(ce.Args) == 0 { + ce.Reply("Usage: import |contacts") + return + } + user := ce.User if ce.Args[0] == "contacts" {