Skip to content

Commit

Permalink
Merge commit 'refs/pull/5204/merge' of https://github.com/Cog-Creator…
Browse files Browse the repository at this point in the history
…s/Red-DiscordBot into V3/dpy2_unstable
  • Loading branch information
Jackenmen committed Mar 21, 2022
2 parents 0af3a7d + 03622bc commit 1f7365e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion redbot/cogs/audio/core/events/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,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)
Expand Down
11 changes: 4 additions & 7 deletions redbot/cogs/audio/core/events/lavalink.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import discord
import lavalink
from discord.backoff import ExponentialBackoff
from discord.gateway import DiscordWebSocket
from red_commons.logging import getLogger

from redbot.core.i18n import Translator, set_contextual_locales_from_guild
Expand Down Expand Up @@ -333,14 +332,13 @@ 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():
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()
Expand Down Expand Up @@ -380,7 +378,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 shard.is_closed():
if player._con_delay:
delay = player._con_delay.delay()
else:
Expand All @@ -392,7 +390,7 @@ 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,
shard.is_closed(),
code,
by_remote,
reason,
Expand All @@ -405,8 +403,7 @@ async def _websocket_closed_handler(
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 shard.is_closed():
await asyncio.sleep(0.1)

if has_perm and player.current and player.is_playing:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ install_requires =
pytz==2021.1
PyYAML==5.4.1
Red-Commons==1.0.0
Red-Lavalink==0.9.0
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
Expand Down

0 comments on commit 1f7365e

Please sign in to comment.