How to check whether a user can be DMed?

See title. The best I can figure out is actually trying to send a DM, but by the point I'm doing that there's nothing I can do if it fails, so it would be nice if there's a better way to check.
5 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna4mo ago
The only way is by sending a dm and catching the rejection
ElJay
ElJayOP4mo ago
Here's the relevant use case: 1. User runs /remind command. 2. At the specified time user is DMed with the reminder. I would like to confirm that the bot can DM the user when the command is run, because when it's time to send the reminder I can't do anything if it fails. but sounds like that requires sending a dm and there's not anything I can do about that
treble/luna
treble/luna4mo ago
There indeed is no other way of knowing other than sending the dm and catching the rejection
ElJay
ElJayOP4mo ago
yep. thanks

Did you find this page helpful?