1
0
Fork 0
mirror of synced 2024-06-28 03:00:55 +12:00

Cleaned up the join/leave methods

This commit is contained in:
Phxntxm 2016-10-03 20:04:03 -05:00
parent a167a034d1
commit e57ca780ef

12
bot.py
View file

@ -49,8 +49,10 @@ async def on_ready():
@bot.event @bot.event
async def on_member_join(member): async def on_member_join(member):
r_filter = {'server_id': member.server.id} server = member.server
r_filter = {'server_id': server.id}
notifications = await config.get_content('user_notifications', r_filter) notifications = await config.get_content('user_notifications', r_filter)
try: try:
channel_id = notifications[0]['channel_id'] channel_id = notifications[0]['channel_id']
except TypeError: except TypeError:
@ -60,14 +62,16 @@ async def on_member_join(member):
if not channel_id: if not channel_id:
return return
channel = discord.utils.get(member.server.channels, id=notifications) channel = server.get_channel(channel_id)
await bot.send_message(channel, "Welcome to the '{0.server.name}' server {0.mention}!".format(member)) await bot.send_message(channel, "Welcome to the '{0.server.name}' server {0.mention}!".format(member))
@bot.event @bot.event
async def on_member_remove(member): async def on_member_remove(member):
r_filter = {'server_id': member.server.id} server = member.server
r_filter = {'server_id': server.id}
notifications = await config.get_content('user_notifications', r_filter) notifications = await config.get_content('user_notifications', r_filter)
try: try:
channel_id = notifications[0]['channel_id'] channel_id = notifications[0]['channel_id']
except TypeError: except TypeError:
@ -77,7 +81,7 @@ async def on_member_remove(member):
if not channel_id: if not channel_id:
return return
channel = discord.utils.get(member.server.channels, id=channel_id) channel = server.get_channel(channel_id)
await bot.send_message(channel, await bot.send_message(channel,
"{0} has left the server, I hope it wasn't because of something I said :c".format( "{0} has left the server, I hope it wasn't because of something I said :c".format(
member.display_name)) member.display_name))