From b0a138158946521dfc29329d92245cb544f91a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Mon, 19 Dec 2022 00:22:51 +0100 Subject: [PATCH] Fix command label being passed as arg in case of no args --- .../wtf/beatrice/hidekobot/commands/message/SayCommand.java | 4 ++-- .../beatrice/hidekobot/listeners/MessageCommandListener.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java b/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java index aa7c162..27e3751 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java @@ -34,8 +34,8 @@ public class SayCommand implements MessageCommand public void runCommand(MessageReceivedEvent event, String label, String[] args) { - String messageContent = ""; - if(args.length != 0) + String messageContent; + if(args.length != 0 && !args[0].isEmpty()) { messageContent = args[0]; } else { diff --git a/src/main/java/wtf/beatrice/hidekobot/listeners/MessageCommandListener.java b/src/main/java/wtf/beatrice/hidekobot/listeners/MessageCommandListener.java index 84fe056..bf16c3b 100644 --- a/src/main/java/wtf/beatrice/hidekobot/listeners/MessageCommandListener.java +++ b/src/main/java/wtf/beatrice/hidekobot/listeners/MessageCommandListener.java @@ -123,7 +123,7 @@ public class MessageCommandListener extends ListenerAdapter { // remove first argument, which is the command label - argsString = argsString.replaceAll("^[\\S]+\\s+", ""); + argsString = argsString.replaceAll("^[\\S]+\\s*", ""); // pass all other arguments as a single argument as the first array element commandArgs = new String[]{argsString}; }