knights-of-academia / horace

discord.js bot powering the Knights of Academia server with commands like info, AFK, and more
MIT License
23 stars 19 forks source link

Fix bot crash when user prevents inbound DMs #286

Closed catalincodes closed 2 years ago

catalincodes commented 2 years ago

Without this fix, having a try-catch around the user.send(message) , if the user has DMs blocked using Server privacy settings or using the Discord settings, the bot can crash.

This fix ensures that the commands !help, !remind and !highlight work properly when users have DMs disabled.

Also, in order to reduce code repetition a wrapper for the DM message sending mechanism has been added.

Validation has been peformed. All tests are passing with no linting errors.

cjtheham commented 2 years ago

OK - Alex gave the go-ahead! If you can, go ahead and add the following link to the reply message with some text along the lines of "Here's how to allow me to direct message you!"

https://support.discord.com/hc/en-us/articles/217916488-Blocking-Privacy-Settings- and then add a note or something that says "instead of blocking messages, be sure to toggle this setting off to allow messages."

Let me know if this makes the message too long.