Function always returns "true".
Hi everyone,
I've created a function that checks if a user can be DMed. However, it always returns true, regardless of the user's permissions.
Here's the snippet:
I've been testing it on myself, but it consistently returns true, even when it shouldn't. The function should catch an error at user.createDM(), but it doesn't seem to.
I might be overlooking something. Might someone help me point out the issue?
4 Replies
- 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!try...catch
only catches promise rejections if you await
the promise
You made it an async function already, so theres no reason not to
Also, I believe you need to actually send a message for it to reject
There's no other way to check if DMs are possible until you try and do soInteresting, ill figure it out.
Thank you.
yeah best way to handle it really is just to try sending the dm if it fails just handle the error with the try catch and move on
if i may ask what is your intended use for the function (i.e. why are you using it) it might help me give you some better advice on how to proceed