SFUAnime / Ren

As a mascot for the SFU Anime Club, Ren is our in-house Discord bot. Includes first/third party modules that are in use.
GNU General Public License v3.0
19 stars 21 forks source link

[Birthday] Fix DM case where DM is not established #654

Closed Injabie3 closed 1 year ago

Injabie3 commented 1 year ago

Description of the changes

This commit fixes SFUAnime/Ren#629 , which raises AttributeError when trying to run [p]birthday self set. The root cause is when a user has not had a DM session with the bot before, then dm_channel for that user will return NoneType.

Since the mainFlow helper uses the send method on a channel, we can instead substitute it for a Messageable type, and replace dm_channel with the user itself, and we can still use either the triggering ctx.channel or ctx.author

Tested with the help of @abelathomas : image