Skip to content

MediaOnlyChannelListener DM failure shouldnt result in an error #748

@Zabuzard

Description

@Zabuzard

The MediaOnlyChannelListener 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:

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.mediaonly.MediaOnlyChannelListener.onMessageReceived(MediaOnlyChannelListener.java:48)
at org.togetherjava.tjbot.commands.system.BotCore.lambda$onMessageReceived$9(BotCore.java:205)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java...

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

code

Even better would be to send a message in the channel that pings the user instead and then delete that message after a minute again. But its also okay to go without that for now.

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