Change order of channel checking to ensure it exists
This commit is contained in:
parent
c7742a8023
commit
b897740e76
|
@ -88,14 +88,18 @@ class Birthday:
|
||||||
if not server:
|
if not server:
|
||||||
continue
|
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)
|
bds = self.get_birthdays_for_server(server, today=True)
|
||||||
for bd in bds:
|
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:
|
try:
|
||||||
await channel.send("It is {}'s birthday today! "
|
await channel.send("It is {}'s birthday today! "
|
||||||
"Wish them a happy birthday! \N{SHORTCAKE}".format(bd['member'].mention))
|
"Wish them a happy birthday! \N{SHORTCAKE}".format(bd['member'].mention))
|
||||||
|
|
Loading…
Reference in a new issue