From 809518f85fcbee789f9feeb4db9a7afc575e2771 Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Fri, 19 Oct 2018 04:32:03 -0300 Subject: [PATCH] blueprints.guilds: add create_guild_settings --- litecord/blueprints/guilds.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 86b627c..b7967d9 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -26,6 +26,16 @@ async def guild_owner_check(user_id: int, guild_id: int): raise Forbidden('You are not the owner of the guild') +async def create_guild_settings(guild_id: int, user_id: int): + """Create guild settings for the user + joining the guild.""" + + await app.db.execute(""" + INSERT INTO guild_settings (user_id, guild_id) + VALUES ($1, $2) + """, user_id, guild_id) + + @bp.route('', methods=['POST']) async def create_guild(): user_id = await token_check() @@ -49,6 +59,8 @@ async def create_guild(): VALUES ($1, $2) """, user_id, guild_id) + await create_guild_settings(guild_id, user_id) + await app.db.execute(""" INSERT INTO roles (id, guild_id, name, position, permissions) VALUES ($1, $2, $3, $4, $5)