sharding (status): Use sessions for bot status.
Uses the `current_sessions` table to generate the status summary.
This commit is contained in:
@@ -13,19 +13,13 @@ async def update_status():
|
|||||||
# TODO: Make globally configurable and saveable
|
# TODO: Make globally configurable and saveable
|
||||||
global _last_update
|
global _last_update
|
||||||
|
|
||||||
if time.time() - _last_update < 30:
|
if time.time() - _last_update < 60:
|
||||||
return
|
return
|
||||||
|
|
||||||
_last_update = time.time()
|
_last_update = time.time()
|
||||||
|
|
||||||
student_count = sum(
|
student_count, room_count = client.data.current_sessions.select_one_where(
|
||||||
len(ch.members)
|
select_columns=("COUNT(*) AS studying_count", "COUNT(DISTINCT(channelid)) AS channel_count"),
|
||||||
for guild in client.guilds
|
|
||||||
for ch in guild.voice_channels
|
|
||||||
)
|
|
||||||
room_count = sum(
|
|
||||||
len([vc for vc in guild.voice_channels if vc.members])
|
|
||||||
for guild in client.guilds
|
|
||||||
)
|
)
|
||||||
status = "{} students in {} study rooms!".format(student_count, room_count)
|
status = "{} students in {} study rooms!".format(student_count, room_count)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user