diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index d5b9375..9317429 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -21,7 +21,12 @@ from typing import Optional, List from quart import Blueprint, request, current_app as app, jsonify -from litecord.common.guilds import create_role, create_guild_channel, delete_guild +from litecord.common.guilds import ( + create_role, + create_guild_channel, + delete_guild, + create_guild_settings, +) from ..auth import token_check from ..snowflake import get_snowflake @@ -44,34 +49,6 @@ DEFAULT_EVERYONE_PERMS = 104324161 bp = Blueprint("guilds", __name__) -async def create_guild_settings(guild_id: int, user_id: int): - """Create guild settings for the user - joining the guild.""" - - # new guild_settings are based off the currently - # set guild settings (for the guild) - m_notifs = await app.db.fetchval( - """ - SELECT default_message_notifications - FROM guilds - WHERE id = $1 - """, - guild_id, - ) - - await app.db.execute( - """ - INSERT INTO guild_settings - (user_id, guild_id, message_notifications) - VALUES - ($1, $2, $3) - """, - user_id, - guild_id, - m_notifs, - ) - - async def add_member(guild_id: int, user_id: int): """Add a user to a guild.""" await app.db.execute( diff --git a/litecord/blueprints/invites.py b/litecord/blueprints/invites.py index 02b7610..0a9f7d7 100644 --- a/litecord/blueprints/invites.py +++ b/litecord/blueprints/invites.py @@ -28,7 +28,6 @@ from ..auth import token_check from ..schemas import validate, INVITE from ..enums import ChannelType from ..errors import BadRequest, Forbidden -from .guilds import create_guild_settings from ..utils import async_map from litecord.blueprints.checks import ( @@ -39,6 +38,7 @@ from litecord.blueprints.checks import ( ) from litecord.blueprints.dm_channels import gdm_is_member, gdm_add_recipient +from litecord.common.guilds import create_guild_settings log = Logger(__name__) bp = Blueprint("invites", __name__) diff --git a/litecord/common/guilds.py b/litecord/common/guilds.py index f1915e0..d7d1e25 100644 --- a/litecord/common/guilds.py +++ b/litecord/common/guilds.py @@ -204,3 +204,31 @@ async def delete_guild(guild_id: int): # becomes the little memer that tries to fuck up with # everybody's gateway await app.dispatcher.remove("guild", guild_id) + + +async def create_guild_settings(guild_id: int, user_id: int): + """Create guild settings for the user + joining the guild.""" + + # new guild_settings are based off the currently + # set guild settings (for the guild) + m_notifs = await app.db.fetchval( + """ + SELECT default_message_notifications + FROM guilds + WHERE id = $1 + """, + guild_id, + ) + + await app.db.execute( + """ + INSERT INTO guild_settings + (user_id, guild_id, message_notifications) + VALUES + ($1, $2, $3) + """, + user_id, + guild_id, + m_notifs, + )