Skip to content

Commit

Permalink
Merge branch 'inactive-player-timeout'
Browse files Browse the repository at this point in the history
Conflicts:
	musicbot/bot.py
  • Loading branch information
itsTheFae committed Dec 9, 2023
2 parents 133f7c7 + f7a027f commit cd9a7c3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions musicbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def _init_player(self, player, *, guild=None):
async def on_player_play(self, player, entry):
log.debug("Running on_player_play")
await self.reset_player_inactivity(player)
await self.update_now_playing_status(entry)
await self.update_now_playing_status()
# manage the cache since we may have downloaded something.
self.filecache.handle_new_cache_entry(entry)
player.skip_state.reset()
Expand Down Expand Up @@ -712,11 +712,11 @@ async def on_player_play(self, player, entry):
async def on_player_resume(self, player, entry, **_):
log.debug("Running on_player_resume")
await self.reset_player_inactivity(player)
await self.update_now_playing_status(entry)
await self.update_now_playing_status()

async def on_player_pause(self, player, entry, **_):
log.debug("Running on_player_pause")
await self.update_now_playing_status(entry, True)
await self.update_now_playing_status()
self.loop.create_task(self.handle_player_inactivity(player))
# await self.serialize_queue(player.voice_client.channel.guild)

Expand Down Expand Up @@ -853,24 +853,25 @@ async def on_player_error(self, player, entry, ex, **_):
else:
log.exception("Player error", exc_info=ex)

async def update_now_playing_status(self, entry=None, is_paused=False):
async def update_now_playing_status(self):
game = None

if not self.config.status_message:
if self.user.bot:
activeplayers = sum(1 for p in self.players.values() if p.is_playing)
if activeplayers > 1:
game = discord.Game(
type=0, name="music on %s guilds" % activeplayers
)
entry = None
entry = None
paused = False
activeplayers = sum(1 for p in self.players.values() if p.is_playing)
if activeplayers > 1:
game = discord.Game(
type=0, name="music on %s guilds" % activeplayers
)

elif activeplayers == 1:
player = discord.utils.get(self.players.values(), is_playing=True)
entry = player.current_entry
elif activeplayers == 1:
player = discord.utils.get(self.players.values(), is_playing=True)
paused = player.is_paused
entry = player.current_entry

if entry:
prefix = "\u275A\u275A " if is_paused else ""
prefix = "\u275A\u275A " if paused else ""

name = "{}{}".format(prefix, entry.title)[:128]
game = discord.Game(type=0, name=name)
Expand Down

0 comments on commit cd9a7c3

Please sign in to comment.