fix (rooms): Avoid loading rooms in dead guilds.
This commit is contained in:
@@ -218,6 +218,9 @@ class TimeSlot:
|
|||||||
"""
|
"""
|
||||||
Load data and update applicable caches.
|
Load data and update applicable caches.
|
||||||
"""
|
"""
|
||||||
|
if not self.guild:
|
||||||
|
return self
|
||||||
|
|
||||||
# Load setting data
|
# Load setting data
|
||||||
self.category = GuildSettings(self.guild.id).accountability_category.value
|
self.category = GuildSettings(self.guild.id).accountability_category.value
|
||||||
self.lobby = GuildSettings(self.guild.id).accountability_lobby.value
|
self.lobby = GuildSettings(self.guild.id).accountability_lobby.value
|
||||||
@@ -389,13 +392,14 @@ class TimeSlot:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Reward members appropriately
|
# Reward members appropriately
|
||||||
guild_settings = GuildSettings(self.guild.id)
|
if self.guild:
|
||||||
reward = guild_settings.accountability_reward.value
|
guild_settings = GuildSettings(self.guild.id)
|
||||||
if all(mem.has_attended for mem in self.members.values()):
|
reward = guild_settings.accountability_reward.value
|
||||||
reward += guild_settings.accountability_bonus.value
|
if all(mem.has_attended for mem in self.members.values()):
|
||||||
|
reward += guild_settings.accountability_bonus.value
|
||||||
|
|
||||||
for memid in self.members:
|
for memid in self.members:
|
||||||
Lion.fetch(self.guild.id, memid).addCoins(reward)
|
Lion.fetch(self.guild.id, memid).addCoins(reward)
|
||||||
|
|
||||||
async def cancel(self):
|
async def cancel(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -374,14 +374,15 @@ async def _accountability_system_resume():
|
|||||||
None, mow.slotid, mow.userid)
|
None, mow.slotid, mow.userid)
|
||||||
for mow in slot_members[row.slotid] if mow.last_joined_at
|
for mow in slot_members[row.slotid] if mow.last_joined_at
|
||||||
)
|
)
|
||||||
slot = TimeSlot(client.get_guild(row.guildid), row.start_at, data=row).load(
|
if client.get_guild(row.guildid):
|
||||||
memberids=[mow.userid for mow in slot_members[row.slotid]]
|
slot = TimeSlot(client.get_guild(row.guildid), row.start_at, data=row).load(
|
||||||
)
|
memberids=[mow.userid for mow in slot_members[row.slotid]]
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
await slot.close()
|
||||||
|
except discord.HTTPException:
|
||||||
|
pass
|
||||||
row.closed_at = now
|
row.closed_at = now
|
||||||
try:
|
|
||||||
await slot.close()
|
|
||||||
except discord.HTTPException:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Load the in-progress room data
|
# Load the in-progress room data
|
||||||
if current_room_data:
|
if current_room_data:
|
||||||
@@ -451,7 +452,7 @@ async def launch_accountability_system(client):
|
|||||||
guilds = tables.guild_config.fetch_rows_where(
|
guilds = tables.guild_config.fetch_rows_where(
|
||||||
accountability_category=NOTNULL
|
accountability_category=NOTNULL
|
||||||
)
|
)
|
||||||
[AccountabilityGuild(guild.guildid) for guild in guilds]
|
[AccountabilityGuild(guild.guildid) for guild in guilds if client.get_guild(guild.guildid)]
|
||||||
await _accountability_system_resume()
|
await _accountability_system_resume()
|
||||||
asyncio.create_task(_accountability_loop())
|
asyncio.create_task(_accountability_loop())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user