From 6bf9ff563751ce5f57c37e29403d7dac512b0cc3 Mon Sep 17 00:00:00 2001 From: Draper <27962761+Drapersniper@users.noreply.github.com> Date: Fri, 20 Dec 2019 06:59:09 +0000 Subject: [PATCH] [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> --- changelog.d/audio/3123.bugfix.rst | 1 + redbot/cogs/audio/audio.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog.d/audio/3123.bugfix.rst diff --git a/changelog.d/audio/3123.bugfix.rst b/changelog.d/audio/3123.bugfix.rst new file mode 100644 index 000000000..e639ae043 --- /dev/null +++ b/changelog.d/audio/3123.bugfix.rst @@ -0,0 +1 @@ +Fix a console spam caused sometimes when auto disconnect and auto pause are used. \ No newline at end of file diff --git a/redbot/cogs/audio/audio.py b/redbot/cogs/audio/audio.py index 6bb3229df..00af5e97e 100644 --- a/redbot/cogs/audio/audio.py +++ b/redbot/cogs/audio/audio.py @@ -6749,8 +6749,10 @@ class Audio(commands.Cog): player = lavalink.get_player(sid) await player.stop() await player.disconnect() - except Exception: + except Exception as err: 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 elif ( 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: try: 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( "Exception raised in Audio's emptypause_timer.", exc_info=True )