Skip to content

ScamBlocker crashes if given empty list of actions #749

@Zabuzard

Description

@Zabuzard

The ScamBlocker can display a number of actions (buttons) on its message. In a few of its flows, it uses List.of() (empty list) as list-of-buttons, when it does not want to show any buttons.

However, this leads to the code using .setActionRow(confirmDialog) (where latter is the empty list), running into a check of JDA that throws:

One of the EventListeners had an uncaught exception

java.lang.IllegalArgumentException: Cannot have empty row!
at net.dv8tion.jda.internal.utils.Checks.check(Checks.java:61)
at net.dv8tion.jda.api.interactions.components.ActionRow.of(ActionRow.java:119)
at net.dv8tion.jda.api.interactions.components.ActionRow.of(ActionRow.java:100)
at net.dv8tion.jda.api.utils.messages.MessageRequest.setActionRow(MessageRequest.java:291)
at org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker.reportScamMessage(ScamBlocker.java:246)
at org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker.takeActionAutoDeleteAndQuarantine(ScamBlocker.java:190)
at org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker.takeAction(ScamBlocker.java:161)
at org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker.onMessageReceived(ScamBlocker.java:140)
at org.togetherjava.tjbot.commands.system.BotCore.lambda$onMessageReceived$9(BotCore.java:205)
at java.base/java.util.stream.ForEac...

The fix is simple. If the list is empty, it must not use .setActionRow, but simply skip that part of the code.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions