Revxrsal / Lamp

A modern annotations-driven commands framework for Java and Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoSuchElementException when dispatching command with ArgumentStack with empty String

bivashy opened this issue · comments

Error occurs with jda module. When user sends picture, or emote MessageReceivedEvent occurs, and MessageReceivedEvent#getMessage#getContentRaw returns empty string.

java.util.NoSuchElementException
at java.util.LinkedList.getFirst(LinkedList.java:244)
at revxrsal.commands.core.BaseCommandDispatcher.eval([BaseCommandDispatcher.java:33](https://github.com/Revxrsal/Lamp/blob/5d00ebe8ec30e2f5f24db5d57717fc0a682c8eb2/common/src/main/java/revxrsal/commands/core/BaseCommandDispatcher.java#L33))
at revxrsal.commands.core.BaseCommandHandler.dispatch([BaseCommandHandler.java:519](https://github.com/Revxrsal/Lamp/blob/5d00ebe8ec30e2f5f24db5d57717fc0a682c8eb2/common/src/main/java/revxrsal/commands/core/BaseCommandHandler.java#L519))

I think it occurs because BaseCommandHandler#parseArguments returns ArgumentStack.empty() when string empty.

So if we add something like this to the BaseCommandDispatcher#eval:

if(arguments.isEmpty()) throw new InvalidCommandException("", "");

Everything will be fine

commented

Thank you for the report. I guess a simple check that ignores any empty messages should do the job.

Thank you for the report. I guess a simple check that ignores any empty messages should do the job.

Thank you for replying too. Good luck!

commented

Can you check if 5080dce fixes this issue?

I checked, and it fixed the issue.

Sorry for delay

Thank you!