Changed yt-ratelimit to optional
This commit is contained in:
@@ -43,6 +43,7 @@ from discord import (
|
||||
)
|
||||
|
||||
from discord.ext import commands
|
||||
|
||||
from . import events
|
||||
from .enums import SearchType, LoopType, RequestMethod
|
||||
from .events import VoicelinkEvent, TrackEndEvent, TrackStartEvent, TrackExceptionEvent
|
||||
@@ -352,7 +353,8 @@ class Player(VoiceProtocol):
|
||||
self._current = None
|
||||
|
||||
if isinstance(event, TrackExceptionEvent) and event.exception["message"] == "This content isn’t available.":
|
||||
await self._node.yt_ratelimit.flag_active_token()
|
||||
if self._node.yt_ratelimit:
|
||||
await self._node.yt_ratelimit.flag_active_token()
|
||||
|
||||
event.dispatch(self._bot)
|
||||
|
||||
@@ -438,16 +440,14 @@ class Player(VoiceProtocol):
|
||||
self.controller = await self.context.channel.send(embed=embed, view=view)
|
||||
|
||||
elif not await self.is_position_fresh():
|
||||
try:
|
||||
await self.controller.delete()
|
||||
except Exception as e:
|
||||
self._logger.warning(
|
||||
f"Failed to delete outdated controller in {self.guild.name}({self.guild.id}): {e}"
|
||||
)
|
||||
await self.controller.delete()
|
||||
self.controller = await self.context.channel.send(embed=embed, view=view)
|
||||
|
||||
else:
|
||||
await self.controller.edit(embed=embed, view=view)
|
||||
|
||||
except errors.Forbidden:
|
||||
self._logger.warning(f"Missing permission to update the music controller on {self.guild.name}({self.guild.id})")
|
||||
|
||||
except Exception as e:
|
||||
self._logger.error(f"Something went wrong while sending music controller to {self.guild.name}({self.guild.id})", exc_info=e)
|
||||
@@ -577,7 +577,8 @@ class Player(VoiceProtocol):
|
||||
data["endTime"] = str(end if end else track.end_time)
|
||||
|
||||
await self.send(method=RequestMethod.PATCH, query=f"noReplace={ignore_if_playing}", data=data)
|
||||
await self.node.yt_ratelimit.handle_request()
|
||||
if self._node.yt_ratelimit:
|
||||
await self._node.yt_ratelimit.handle_request()
|
||||
|
||||
self._current = track
|
||||
|
||||
|
||||
@@ -87,9 +87,9 @@ class Node:
|
||||
port: int,
|
||||
password: str,
|
||||
identifier: str,
|
||||
yt_ratelimit: dict,
|
||||
secure: bool = False,
|
||||
heartbeat: int = 30,
|
||||
yt_ratelimit: dict = None,
|
||||
session: Optional[aiohttp.ClientSession] = None,
|
||||
spotify_client_id: Optional[str] = None,
|
||||
spotify_client_secret: Optional[str] = None,
|
||||
@@ -131,7 +131,7 @@ class Node:
|
||||
self._spotify_client_secret: Optional[str] = spotify_client_secret
|
||||
self._spotify_client: Optional[spotify.Client] = None
|
||||
|
||||
self.yt_ratelimit: YTRatelimit = STRATEGY.get(yt_ratelimit.get("strategy"))(self, yt_ratelimit)
|
||||
self.yt_ratelimit: Optional[YTRatelimit] = STRATEGY.get(yt_ratelimit.get("strategy"))(self, yt_ratelimit) if yt_ratelimit else None
|
||||
|
||||
self._bot.add_listener(self._update_handler, "on_socket_response")
|
||||
|
||||
@@ -636,9 +636,9 @@ class NodePool:
|
||||
port: str,
|
||||
password: str,
|
||||
identifier: str,
|
||||
yt_ratelimit: dict,
|
||||
secure: bool = False,
|
||||
heartbeat: int = 30,
|
||||
yt_ratelimit: dict = None,
|
||||
spotify_client_id: Optional[str] = None,
|
||||
spotify_client_secret: Optional[str] = None,
|
||||
session: Optional[aiohttp.ClientSession] = None,
|
||||
@@ -656,7 +656,7 @@ class NodePool:
|
||||
|
||||
node = Node(
|
||||
pool=cls, bot=bot, host=host, port=port, password=password,
|
||||
yt_ratelimit=yt_ratelimit, identifier=identifier, secure=secure, heartbeat=heartbeat,
|
||||
identifier=identifier, secure=secure, heartbeat=heartbeat, yt_ratelimit=yt_ratelimit,
|
||||
session=session, spotify_client_id=spotify_client_id, spotify_client_secret=spotify_client_secret,
|
||||
resume_key=resume_key, logger=logger
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user