From b5b168c3887d41c55f77d007afced9342a30a4d4 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 13 Aug 2022 22:46:31 -0300 Subject: [PATCH] storage: copy guild.region into channel.rtc_region close #130 --- litecord/storage.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/litecord/storage.py b/litecord/storage.py index 3f9b77d..0125817 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -432,7 +432,7 @@ class Storage: return {**row, **drow} elif chan_type == ChannelType.GUILD_VOICE: - vrow = await self.db.fetchrow( + voice_channel_data = await self.db.fetchrow( """ SELECT bitrate, user_limit FROM guild_voice_channels @@ -441,7 +441,20 @@ class Storage: row["id"], ) - return {**row, **dict(vrow)} + guild_region = await self.db.fetchval( + """ + SELECT region + FROM guilds + WHERE guild.id = $1 + """, + guild_id, + row["guild_id"], + ) + + # see https://gitlab.com/litecord/litecord/-/issues/130 + voice_channel_data["rtc_region"] = guild_region + + return {**row, **dict(voice_channel_data)} else: # this only exists to trick mypy. this codepath is unreachable raise AssertionError("Unreachable code path.")