fix (core init): Handle preload with no members.

Fixes an issue where bot would crash when loaded with no active members.
This commit is contained in:
2021-10-19 16:18:44 +03:00
parent 93dcb6bd24
commit af49a3cde6

View File

@@ -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. Loads the plain guild configuration for all guilds the client is part of into data.
""" """
guildids = [guild.id for guild in client.guilds] guildids = [guild.id for guild in client.guilds]
rows = client.data.guild_config.fetch_rows_where(guildid=guildids) if guildids:
client.log( rows = client.data.guild_config.fetch_rows_where(guildid=guildids)
"Preloaded guild configuration for {} guilds.".format(len(rows)), client.log(
context="CORE_LOADING" "Preloaded guild configuration for {} guilds.".format(len(rows)),
) context="CORE_LOADING"
)
@module.launch_task @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. 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)) 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) if userids:
client.log( rows = client.data.lions.fetch_rows_where(userid=userids)
"Preloaded member data for {} members.".format(len(rows)), client.log(
context="CORE_LOADING" "Preloaded member data for {} members.".format(len(rows)),
) context="CORE_LOADING"
)
@module.launch_task @module.launch_task