1
0
Fork 0
mirror of synced 2024-05-24 14:29:39 +12:00

Removal of default_channel

This commit is contained in:
Phxntxm 2017-07-31 20:39:10 -05:00
parent 48ac555131
commit 0fcd51958a
5 changed files with 14 additions and 22 deletions

View file

@ -73,16 +73,16 @@ class Birthday:
bds = self.get_birthdays_for_server(server, today=True)
for bd in bds:
# Set our default to either the one set, or the default channel of the server
default_channel_id = s.get('notifications', {}).get('default') or server.id
# 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)) or server.default_channel
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))
except (discord.Forbidden, discord.HTTPException):
except (discord.Forbidden, discord.HTTPException, AttributeError):
pass
@commands.group(aliases=['birthdays'], invoke_without_command=True)

View file

@ -63,7 +63,7 @@ class StatsUpdate:
# Get the notifications settings, get the welcome setting
notifications = self.bot.db.load('server_settings', key=guild.id, pluck='notifications') or {}
# Set our default to either the one set, or the default channel of the server
default_channel_id = notifications.get('default') or guild.id
default_channel_id = notifications.get('default')
# If it is has been overriden by picarto notifications setting, use this
channel_id = notifications.get('welcome') or default_channel_id
# Get the message if it exists
@ -78,7 +78,7 @@ class StatsUpdate:
channel = guild.get_channel(int(channel_id))
try:
await channel.send(join_message.format(server=guild.name, member=member.mention))
except (discord.Forbidden, discord.HTTPException):
except (discord.Forbidden, discord.HTTPException, AttributeError):
pass
async def on_member_remove(self, member):
@ -91,7 +91,7 @@ class StatsUpdate:
# Get the notifications settings, get the welcome setting
notifications = self.bot.db.load('server_settings', key=guild.id, pluck='notifications') or {}
# Set our default to either the one set, or the default channel of the server
default_channel_id = notifications.get('default') or guild.id
default_channel_id = notifications.get('default')
# If it is has been overriden by picarto notifications setting, use this
channel_id = notifications.get('welcome') or default_channel_id
# Get the message if it exists
@ -106,7 +106,7 @@ class StatsUpdate:
channel = guild.get_channel(int(channel_id))
try:
await channel.send(leave_message.format(server=guild.name, member=member.name))
except (discord.Forbidden, discord.HTTPException):
except (discord.Forbidden, discord.HTTPException, AttributeError):
pass

View file

@ -107,19 +107,16 @@ class Picarto:
# Get the notifications settings, get the picarto setting
notifications = self.bot.db.load('server_settings', key=s_id, pluck='notifications') or {}
# Set our default to either the one set, or the default channel of the server
default_channel_id = notifications.get('default') or s_id
default_channel_id = notifications.get('default')
# If it is has been overriden by picarto notifications setting, use this
channel_id = notifications.get('picarto') or default_channel_id
# Now get the channel
channel = server.get_channel(int(channel_id))
# Unfortunately we need one more check, to ensure a channel hasn't been chosen, then deleted
if channel is None:
channel = server.default_channel
# Then just send our message
try:
await channel.send(msg.format(member=member), embed=embed)
except (discord.Forbidden, discord.HTTPException):
except (discord.Forbidden, discord.HTTPException, AttributeError):
pass
await asyncio.sleep(30)

View file

@ -74,13 +74,11 @@ class Raffle:
# Get the notifications settings, get the raffle setting
notifications = self.bot.db.load('server_settings', key=server.id, pluck='notifications') or {}
# Set our default to either the one set, or the default channel of the server
default_channel_id = notifications.get('default') or server.id
# Set our default to either the one set
default_channel_id = notifications.get('default')
# If it is has been overriden by picarto notifications setting, use this
channel_id = notifications.get('raffle') or default_channel_id
channel = self.bot.get_channel(int(channel_id))
if channel is None:
channel = server.default_channel
try:
await channel.send(fmt)
except (discord.Forbidden, AttributeError):

View file

@ -119,19 +119,16 @@ class Twitch:
# Get the notifications settings, get the twitch setting
notifications = self.bot.db.load('server_settings', key=s_id, pluck='notifications') or {}
# Set our default to either the one set, or the default channel of the server
default_channel_id = notifications.get('default') or s_id
default_channel_id = notifications.get('default')
# If it is has been overriden by twitch notifications setting, use this
channel_id = notifications.get('twitch') or default_channel_id
# Now get the channel
channel = server.get_channel(int(channel_id))
# Unfortunately we need one more check, to ensure a channel hasn't been chosen, then deleted
if channel is None:
channel = server.default_channel
# Then just send our message
try:
await channel.send(msg.format(member=member), embed=embed)
except (discord.Forbidden, discord.HTTPException):
except (discord.Forbidden, discord.HTTPException, AttributeError):
pass
await asyncio.sleep(30)