Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle error when a user is blocking the bot from sending a private message #3

Open
connorhsm opened this issue Feb 24, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@connorhsm
Copy link
Member

As per the title, there are cases when a user has settings which prevent the bot from sending them a private message. This error should be handled in dictator.py along with other error handling which will trigger the bot to tag the user and alert them of the problem in the bot topic channel.

@connorhsm connorhsm added the bug Something isn't working label Feb 24, 2020
@connorhsm
Copy link
Member Author

connorhsm commented Apr 14, 2020

Error message:

COMMAND ERROR:
Author: Colin#0000
Channel: bot-topic
Command: -key
Command raised an exception: Forbidden: 403 Forbidden (error code: 50007): Cannot send messages to this user

@connorhsm connorhsm self-assigned this Jan 10, 2021
@connorhsm
Copy link
Member Author

This is a bit more tedious than expected...

When a user runs a command and the bot does not have permission to message that user, the commands.CommandInvokeError error is thrown.
But this error is also thrown for other errors, when a user issues the command, such as if the database credentials or permissions are mis-configured.

BUT, if an event is the reason an error occurs, a completely different error is thrown, which is completely out of scope of the commands extension errors because it wasn't sourced from the issuing of a command sigh

This second case is the more important one which occurs more frequently.

I need to split this up so I can chip away at it.

@connorhsm
Copy link
Member Author

The latest related commit handles the case where a user issues a command, but the bot lacks permissions to message them.

To resolve this issue I need to handle the case where an event occurs (a user joining the guild) and the bot lacks permissions to message them.

@TanyaPegasus
Copy link
Member

Is this helpful?
image

If I'm understanding how this works correctly, you, could run something like that prior to attempting to send the message. If it returns that their DMs are open, send the message, otherwise, either don't even try, or send a message in a channel and mention them instead.

You were talking about sending some sort of survey. This could be relevant to that too.

@connorhsm
Copy link
Member Author

Looks like the solution. This hasn't been a pressing issue and will take a deep dive to review the number of areas effected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants