1
0
Fork 0
mirror of synced 2024-05-06 21:52:30 +12:00

Change order of channel checking to ensure it exists

This commit is contained in:
phxntxm 2018-09-23 00:18:13 -05:00
parent c7742a8023
commit b897740e76

View file

@ -88,14 +88,18 @@ class Birthday:
if not server:
continue
# Set our default to either the one set
default_channel_id = s.get('notifications', {}).get('default')
# If it is has been overriden by picarto notifications setting, use this
channel_id = s.get('notifications', {}).get('birthday') or default_channel_id
if not channel_id:
continue
# Now get the channel based on that ID
channel = server.get_channel(int(channel_id))
bds = self.get_birthdays_for_server(server, today=True)
for bd in bds:
# Set our default to either the one set
default_channel_id = s.get('notifications', {}).get('default')
# If it is has been overriden by picarto notifications setting, use this
channel_id = s.get('notifications', {}).get('birthday') or default_channel_id
# Now get the channel based on that ID
channel = server.get_channel(int(channel_id))
try:
await channel.send("It is {}'s birthday today! "
"Wish them a happy birthday! \N{SHORTCAKE}".format(bd['member'].mention))