Pull request #5: Bugfix/server edit broken

Merge in LIT/litecord from bugfix/server-edit-broken to master

* commit 'd9940b9d3f2c305fc2737643a1f153515e64d48c':
  Make rules_channel_id a bigint
  add rules_channel_id to schemas
  Create rules channel
  Fix server update problems (string where supposed to be int)
This commit is contained in:
George Tsatsis 2020-03-30 18:17:22 +00:00
commit e8c3aa02b4
4 changed files with 6 additions and 4 deletions

View File

@ -316,9 +316,9 @@ async def _update_guild(guild_id):
guild_id, guild_id,
) )
channel_fields = ["afk_channel_id", "system_channel_id"] channel_fields = ["afk_channel_id", "system_channel_id", "rules_channel_id"]
for field in [f for f in channel_fields if f in j]: for field in [f for f in channel_fields if f in j]:
# setting to null should remove the link between the afk/sys channel # setting to null should remove the link between the afk/sys/rules channel
# to the guild. # to the guild.
if j[field] is None: if j[field] is None:
await app.db.execute( await app.db.execute(
@ -346,7 +346,7 @@ async def _update_guild(guild_id):
SET {field} = $1 SET {field} = $1
WHERE id = $2 WHERE id = $2
""", """,
j[field], int(j[field]),
guild_id, guild_id,
) )

View File

@ -292,6 +292,7 @@ GUILD_UPDATE = {
"owner_id": {"type": "snowflake", "required": False}, "owner_id": {"type": "snowflake", "required": False},
"system_channel_id": {"type": "snowflake", "required": False, "nullable": True}, "system_channel_id": {"type": "snowflake", "required": False, "nullable": True},
"features": {"type": "list", "required": False, "schema": {"type": "string"}}, "features": {"type": "list", "required": False, "schema": {"type": "string"}},
"rules_channel_id": {"type": "snowflake", "required": False, "nullable": True},
} }

View File

@ -201,7 +201,7 @@ class Storage:
explicit_content_filter, mfa_level, explicit_content_filter, mfa_level,
embed_enabled, embed_channel_id::text, embed_enabled, embed_channel_id::text,
widget_enabled, widget_channel_id::text, widget_enabled, widget_channel_id::text,
system_channel_id::text, features, system_channel_id::text, rules_channel_id::text, features,
banner, description banner, description
FROM guilds FROM guilds
WHERE guilds.id = $1 WHERE guilds.id = $1

View File

@ -0,0 +1 @@
ALTER TABLE guilds ADD COLUMN rules_channel_id bigint