Skip to content

Commit

Permalink
fix stat checks
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahCxrest authored Jan 7, 2025
1 parent c8782b0 commit cffa993
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tasks/statistics_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from utils.prc_api import Player, ServerStatus
from utils.utils import fetch_get_channel

async def update_channel(guild, channel_id, stat, placeholders):
async def update_channel(guild, stat_config, placeholders):
try:
format_string = stat["format"]
channel_id = int(channel_id)
channel_id = stat_config["channel"]
format_string = stat_config["format"]
channel = await fetch_get_channel(guild, channel_id)
if channel:
for key, value in placeholders.items():
Expand All @@ -22,8 +22,7 @@ async def update_channel(guild, channel_id, stat, placeholders):
else:
logging.error(f"Channel {channel_id} not found in guild {guild.id}")
except Exception as e:
logging.error(f"Failed to update channel {channel_id} in guild {guild.id}: {e}", exc_info=True)

logging.error(f"Failed to update channel in guild {guild.id}: {e}", exc_info=True)

@tasks.loop(seconds=45, reconnect=True)
async def statistics_check(bot):
Expand Down Expand Up @@ -70,9 +69,9 @@ async def statistics_check(bot):
"queue": queue
}

tasks = [update_channel(guild, channel_id, stat_value, placeholders) for channel_id, stat_value in
statistics.items()]
tasks = [update_channel(guild, stat_value, placeholders)
for stat_name, stat_value in statistics.items()]
await asyncio.gather(*tasks)

end_time = time.time()
logging.warning(f"Event statistics_check took {end_time - initial_time} seconds")
logging.warning(f"Event statistics_check took {end_time - initial_time} seconds")

0 comments on commit cffa993

Please sign in to comment.