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] `[p]birthday self add` errors out #629

Closed Injabie3 closed 1 year ago

Injabie3 commented 1 year ago

See below when someone tried to add their own birthday three times:

[2023-03-12 18:02:30] [ERROR] red: Exception in command 'birthday self set'
Traceback (most recent call last):                                                              
  File "/home/ubuntu/github/renchan/lib/python3.9/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)                                                           
  File "/home/ubuntu/github/renchan/Ren/cogs/birthday/birthday.py", line 624, in setSelfBirthday                           
    await mainFlow(ctx.author.dm_channel, carefree=True)                                        
  File "/home/ubuntu/github/renchan/Ren/cogs/birthday/birthday.py", line 561, in mainFlow                                  
    await channel.send(                                                              
AttributeError: 'NoneType' object has no attribute 'send'                                       
[2023-03-12 18:02:43] [ERROR] red: Exception in command 'birthday self set'                     
Traceback (most recent call last):                                                              
  File "/home/ubuntu/github/renchan/lib/python3.9/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)                                                
  File "/home/ubuntu/github/renchan/Ren/cogs/birthday/birthday.py", line 624, in setSelfBirthday
    await mainFlow(ctx.author.dm_channel, carefree=True)                                        
  File "/home/ubuntu/github/renchan/Ren/cogs/birthday/birthday.py", line 561, in mainFlow                      
    await channel.send(                                                                         
AttributeError: 'NoneType' object has no attribute 'send'                                                                  
[2023-03-12 18:03:22] [ERROR] red: Exception in command 'birthday self set'                     
Traceback (most recent call last):                                                   
  File "/home/ubuntu/github/renchan/lib/python3.9/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)                                                                                      
  File "/home/ubuntu/github/renchan/Ren/cogs/birthday/birthday.py", line 624, in setSelfBirthday
    await mainFlow(ctx.author.dm_channel, carefree=True)                                        
  File "/home/ubuntu/github/renchan/Ren/cogs/birthday/birthday.py", line 561, in mainFlow       
    await channel.send(                                                                                        
AttributeError: 'NoneType' object has no attribute 'send'   
Injabie3 commented 1 year ago

Root cause is that author.dm_channel can be None if the user has not DM'd the bot before.