From 27a7c7e8ef9e8db7b0b7ef5b06fa13341971f785 Mon Sep 17 00:00:00 2001 From: Luna Date: Thu, 7 Feb 2019 15:43:16 -0300 Subject: [PATCH] guilds: handle when j.icon is not present when creating guild --- litecord/blueprints/guilds.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index cb906bc..bed7881 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -128,7 +128,11 @@ async def create_guild(): guild_id = get_snowflake() - image = await put_guild_icon(guild_id, j['icon']) + if 'icon' in j: + image = await put_guild_icon(guild_id, j['icon']) + image = image.icon_hash + else: + image = None await app.db.execute( """ @@ -136,7 +140,7 @@ async def create_guild(): verification_level, default_message_notifications, explicit_content_filter) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) - """, guild_id, j['name'], j['region'], image.icon_hash, user_id, + """, guild_id, j['name'], j['region'], image, user_id, j.get('verification_level', 0), j.get('default_message_notifications', 0), j.get('explicit_content_filter', 0))