Skip to content

Commit

Permalink
[Core] Added simple stats
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin0216 authored Dec 9, 2023
1 parent 41acbfe commit 8b4e159
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions utils/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,14 @@ async def end_session(
await self._leave(member.guild)
self._cleanup(guild)

async def _get_current_stats(self):
active_player = len(self.bot.voice_clients)

print(f"[Stats] Currently playing in {active_player}/{len(self.bot.guilds)} guilds ({round(active_player/len(self.bot.guilds), 3) * 100}% Usage)")

@commands.Cog.listener()
async def on_wavelink_track_start(self, payload: wavelink.TrackEventPayload):
await self._get_current_stats()
guild = payload.player.guild
try:
if self[guild.id]._timer is not None:
Expand All @@ -902,6 +908,7 @@ async def on_wavelink_track_start(self, payload: wavelink.TrackEventPayload):

@commands.Cog.listener()
async def on_wavelink_track_end(self, payload: wavelink.TrackEventPayload):
await self._get_current_stats()
guild = payload.player.guild
self._playlist.rule(guild.id, self.ui_guild_info(guild.id).skip)
await asyncio.sleep(0.2)
Expand Down

0 comments on commit 8b4e159

Please sign in to comment.