mirror of https://gitlab.com/litecord/litecord.git
guilds: optimize create_guild_settings
we were inserting then updating when we could just insert with the value, lol
This commit is contained in:
parent
7ad1d07682
commit
88d118799f
|
|
@ -43,11 +43,8 @@ async def create_guild_settings(guild_id: int, user_id: int):
|
||||||
"""Create guild settings for the user
|
"""Create guild settings for the user
|
||||||
joining the guild."""
|
joining the guild."""
|
||||||
|
|
||||||
await app.db.execute("""
|
# new guild_settings are based off the currently
|
||||||
INSERT INTO guild_settings (user_id, guild_id)
|
# set guild settings (for the guild)
|
||||||
VALUES ($1, $2)
|
|
||||||
""", user_id, guild_id)
|
|
||||||
|
|
||||||
m_notifs = await app.db.fetchval("""
|
m_notifs = await app.db.fetchval("""
|
||||||
SELECT default_message_notifications
|
SELECT default_message_notifications
|
||||||
FROM guilds
|
FROM guilds
|
||||||
|
|
@ -55,10 +52,11 @@ async def create_guild_settings(guild_id: int, user_id: int):
|
||||||
""", guild_id)
|
""", guild_id)
|
||||||
|
|
||||||
await app.db.execute("""
|
await app.db.execute("""
|
||||||
UPDATE guild_settings
|
INSERT INTO guild_settings
|
||||||
SET message_notifications = $1
|
(user_id, guild_id, message_notifications)
|
||||||
WHERE user_id = $2 AND guild_id = $3
|
VALUES
|
||||||
""", m_notifs, user_id, guild_id)
|
($1, $2, $3)
|
||||||
|
""", user_id, guild_id, m_notifs)
|
||||||
|
|
||||||
|
|
||||||
async def add_member(guild_id: int, user_id: int):
|
async def add_member(guild_id: int, user_id: int):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue