From af49a3cde65b43bd796ea694473345c11d2536f0 Mon Sep 17 00:00:00 2001 From: Conatum Date: Tue, 19 Oct 2021 16:18:44 +0300 Subject: [PATCH] fix (core init): Handle preload with no members. Fixes an issue where bot would crash when loaded with no active members. --- bot/core/module.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bot/core/module.py b/bot/core/module.py index e46f9875..daaa4bc7 100644 --- a/bot/core/module.py +++ b/bot/core/module.py @@ -46,11 +46,12 @@ async def preload_guild_configuration(client): Loads the plain guild configuration for all guilds the client is part of into data. """ guildids = [guild.id for guild in client.guilds] - rows = client.data.guild_config.fetch_rows_where(guildid=guildids) - client.log( - "Preloaded guild configuration for {} guilds.".format(len(rows)), - context="CORE_LOADING" - ) + if guildids: + rows = client.data.guild_config.fetch_rows_where(guildid=guildids) + client.log( + "Preloaded guild configuration for {} guilds.".format(len(rows)), + context="CORE_LOADING" + ) @module.launch_task @@ -59,11 +60,12 @@ async def preload_studying_members(client): Loads the member data for all members who are currently in voice channels. """ userids = list(set(member.id for guild in client.guilds for ch in guild.voice_channels for member in ch.members)) - rows = client.data.lions.fetch_rows_where(userid=userids) - client.log( - "Preloaded member data for {} members.".format(len(rows)), - context="CORE_LOADING" - ) + if userids: + rows = client.data.lions.fetch_rows_where(userid=userids) + client.log( + "Preloaded member data for {} members.".format(len(rows)), + context="CORE_LOADING" + ) @module.launch_task