[Audio] Fix console spam caused by disconnect_timer if a player is destroyed before the task completes (#3123)

* Remove servers from the auto disconnect/pause list is their players no longer exist...
Prevents a console spam

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* Chore

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
This commit is contained in:
Draper 2019-12-20 06:59:09 +00:00 committed by Michael H
parent 0b042532fd
commit 6bf9ff5637
2 changed files with 7 additions and 2 deletions

View File

@ -0,0 +1 @@
Fix a console spam caused sometimes when auto disconnect and auto pause are used.

View File

@ -6749,8 +6749,10 @@ class Audio(commands.Cog):
player = lavalink.get_player(sid) player = lavalink.get_player(sid)
await player.stop() await player.stop()
await player.disconnect() await player.disconnect()
except Exception: except Exception as err:
log.error("Exception raised in Audio's emptydc_timer.", exc_info=True) log.error("Exception raised in Audio's emptydc_timer.", exc_info=True)
if "No such player for that guild" in str(err):
stop_times.pop(sid, None)
pass pass
elif ( elif (
sid in pause_times and await self.config.guild(server_obj).emptypause_enabled() sid in pause_times and await self.config.guild(server_obj).emptypause_enabled()
@ -6759,7 +6761,9 @@ class Audio(commands.Cog):
if (time.time() - pause_times.get(sid)) >= emptypause_timer: if (time.time() - pause_times.get(sid)) >= emptypause_timer:
try: try:
await lavalink.get_player(sid).pause() await lavalink.get_player(sid).pause()
except Exception: except Exception as err:
if "No such player for that guild" in str(err):
pause_times.pop(sid, None)
log.error( log.error(
"Exception raised in Audio's emptypause_timer.", exc_info=True "Exception raised in Audio's emptypause_timer.", exc_info=True
) )