From f6c22e0807c4d1e3497a26d4eebbe429ba21a16b Mon Sep 17 00:00:00 2001 From: PredaaA <46051820+PredaaA@users.noreply.github.com> Date: Sat, 7 Aug 2021 22:33:42 +0200 Subject: [PATCH 1/6] Replace player.manager to player.node --- redbot/cogs/audio/core/events/cog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/audio/core/events/cog.py b/redbot/cogs/audio/core/events/cog.py index 6c44c75b676b..84239257780e 100644 --- a/redbot/cogs/audio/core/events/cog.py +++ b/redbot/cogs/audio/core/events/cog.py @@ -207,7 +207,7 @@ async def on_red_audio_track_auto_play( if notify_channel and has_perms and not player.fetch("autoplay_notified", False): if ( - len(player.manager.players) < 10 + len(player.node.players) < 10 or not player._last_resume and player._last_resume + datetime.timedelta(seconds=60) > datetime.datetime.now(tz=datetime.timezone.utc) From d88e58d87926c49cd3c1879d5d0c34604e4c3ad3 Mon Sep 17 00:00:00 2001 From: PredaaA <46051820+PredaaA@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:05:04 +0200 Subject: [PATCH 2/6] Try using bot.is_closed instead of get_voice_ws. --- redbot/cogs/audio/core/events/lavalink.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/redbot/cogs/audio/core/events/lavalink.py b/redbot/cogs/audio/core/events/lavalink.py index 4eff43c9ebaa..08f4a37d4406 100644 --- a/redbot/cogs/audio/core/events/lavalink.py +++ b/redbot/cogs/audio/core/events/lavalink.py @@ -309,8 +309,6 @@ async def _websocket_closed_handler( await self._ws_resume[guild_id].wait() else: self._ws_resume[guild_id].clear() - node = player.node - voice_ws: DiscordWebSocket = node.get_voice_ws(guild_id) code = extra.get("code") by_remote = extra.get("byRemote", "") reason = extra.get("reason", "No Specified Reason").strip() @@ -349,7 +347,7 @@ async def _websocket_closed_handler( self._ws_op_codes[guild_id]._init(self._ws_op_codes[guild_id]._maxsize) return - if voice_ws.socket._closing or voice_ws.socket.closed or not voice_ws.open: + if self.bot.is_closed(): if player._con_delay: delay = player._con_delay.delay() else: @@ -361,21 +359,17 @@ async def _websocket_closed_handler( "Socket Closed %s. " "Code: %d -- Remote: %s -- %s, %r", guild_id, - voice_ws.socket._closing or voice_ws.socket.closed, + self.bot.is_closed(), code, by_remote, reason, player, ) ws_audio_log.debug( - "Reconnecting to channel %d in guild: %d | %.2fs", - channel_id, - guild_id, - delay, + "Reconnecting to channel %d in guild: %d | %.2fs", channel_id, guild_id, delay ) await asyncio.sleep(delay) - while voice_ws.socket._closing or voice_ws.socket.closed or not voice_ws.open: - voice_ws = node.get_voice_ws(guild_id) + while self.bot.is_closed(): await asyncio.sleep(0.1) if has_perm and player.current and player.is_playing: From 9682b40aca88001232471100aa819c6305148307 Mon Sep 17 00:00:00 2001 From: PredaaA <46051820+PredaaA@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:43:05 +0200 Subject: [PATCH 3/6] Use Shard.is_closed instead of bot.is_closed. --- redbot/cogs/audio/core/events/lavalink.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/redbot/cogs/audio/core/events/lavalink.py b/redbot/cogs/audio/core/events/lavalink.py index 08f4a37d4406..8182b894f223 100644 --- a/redbot/cogs/audio/core/events/lavalink.py +++ b/redbot/cogs/audio/core/events/lavalink.py @@ -303,6 +303,7 @@ async def _websocket_closed_handler( disconnect: bool, ) -> None: guild_id = guild.id + shard = self.bot.shards[guild.shard_id] event_channel_id = extra.get("channelID") try: if not self._ws_resume[guild_id].is_set(): @@ -347,7 +348,7 @@ async def _websocket_closed_handler( self._ws_op_codes[guild_id]._init(self._ws_op_codes[guild_id]._maxsize) return - if self.bot.is_closed(): + if shard.is_closed(): if player._con_delay: delay = player._con_delay.delay() else: @@ -359,7 +360,7 @@ async def _websocket_closed_handler( "Socket Closed %s. " "Code: %d -- Remote: %s -- %s, %r", guild_id, - self.bot.is_closed(), + shard.is_closed(), code, by_remote, reason, @@ -369,7 +370,7 @@ async def _websocket_closed_handler( "Reconnecting to channel %d in guild: %d | %.2fs", channel_id, guild_id, delay ) await asyncio.sleep(delay) - while self.bot.is_closed(): + while shard.is_closed(): await asyncio.sleep(0.1) if has_perm and player.current and player.is_playing: From 5caaa6d967989e3210fe548c7c038669e2bdabc6 Mon Sep 17 00:00:00 2001 From: PredaaA <46051820+PredaaA@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:50:43 +0200 Subject: [PATCH 4/6] Remove unused import. --- redbot/cogs/audio/core/events/lavalink.py | 1 - 1 file changed, 1 deletion(-) diff --git a/redbot/cogs/audio/core/events/lavalink.py b/redbot/cogs/audio/core/events/lavalink.py index 8182b894f223..ce933a2027ea 100644 --- a/redbot/cogs/audio/core/events/lavalink.py +++ b/redbot/cogs/audio/core/events/lavalink.py @@ -8,7 +8,6 @@ import discord import lavalink from discord.backoff import ExponentialBackoff -from discord.gateway import DiscordWebSocket from redbot.core.i18n import Translator, set_contextual_locales_from_guild from ...errors import DatabaseError, TrackEnqueueError From 68ce7b70e0321c2266c818dd65318896faa8cf79 Mon Sep 17 00:00:00 2001 From: PredaaA <46051820+PredaaA@users.noreply.github.com> Date: Mon, 21 Feb 2022 21:42:29 +0100 Subject: [PATCH 5/6] Use RLL PR as dep. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index d783283a62b4..8cfbefc85583 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,7 +66,7 @@ install_requires = python-Levenshtein-wheels==0.13.2 pytz==2021.1 PyYAML==5.4.1 - Red-Lavalink==0.9.0 + Red-Lavalink @ git+https://github.com/Cog-Creators/Red-Lavalink@refs/pull/99/merge#egg=Red-Lavalink rich==10.9.0 schema==0.7.4 six==1.16.0 From 3ab2502e29d910561b2732edc5a234d9898ff98b Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Mon, 21 Mar 2022 16:28:20 +0100 Subject: [PATCH 6/6] Update setup.cfg --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index bbe7f24d9be3..aadf4235ede0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -67,7 +67,7 @@ install_requires = pytz==2021.1 PyYAML==5.4.1 Red-Commons==1.0.0 - Red-Lavalink @ git+https://github.com/PredaaA/Red-Lavalink@feature/dpy-voiceprotocol#egg=Red-Lavalink + Red-Lavalink @ git+https://github.com/Cog-Creators/Red-Lavalink@dpy2_unstable#egg=Red-Lavalink rich==10.9.0 schema==0.7.4 six==1.16.0