Skip to content

ScamBlocker DM failure shouldnt result in an error #747

@Zabuzard

Description

@Zabuzard

The ScamBlocker sends DMs to the authors of a message to inform them about the action. Thats totally fine and expected, but failure to DM a user (for example if they blocked DMs), it should not yield to an exception being thrown in the logs:

net.dv8tion.jda.api.requests.RestAction
ERROR
RestAction queue returned failure: [ErrorResponseException] 50007: Cannot send messages to this user
net.dv8tion.jda.api.exceptions.ContextException
at net.dv8tion.jda.api.exceptions.ContextException.here(ContextException.java:54)
at net.dv8tion.jda.internal.requests.restaction.operator.RestActionOperator.contextWrap(RestActionOperator.java:123)
at net.dv8tion.jda.internal.requests.restaction.operator.FlatMapRestAction.queue(FlatMapRestAction.java:50)
at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:572)
at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:538)
at org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker.dmUser(ScamBlocker.java:256)
at org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker.dmUser(ScamBlocker.java:252)
at org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker.takeActionAutoDeleteAndQuarantine(ScamBlocker.java:189)
at org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker.takeAction(ScamBl...
01/03/2023 5:52 PM

The actual DM sending should probably use mapToResults() and then maybe send a DEBUG level log message:

code

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions