Optimized code

This commit is contained in:
Choco
2024-04-12 19:36:35 +08:00
parent 61b633f643
commit 88a879f98a
7 changed files with 54 additions and 37 deletions

View File

@@ -390,7 +390,10 @@ class Player(VoiceProtocol):
self.controller = await self.context.channel.send(embed=embed, view=view)
elif not await self.is_position_fresh():
await self.controller.delete()
try:
await self.controller.delete()
except:
pass
self.controller = await self.context.channel.send(embed=embed, view=view)
else:
@@ -466,8 +469,9 @@ class Player(VoiceProtocol):
self._node._players[self.guild.id] = self
self._is_connected = True
self._logger.debug(f"Player in {self.guild.name}({self.guild.id}) has been connected to {self.channel.name}({self.channel.id}).")
if self.channel:
self._logger.debug(f"Player in {self.guild.name}({self.guild.id}) has been connected to {self.channel.name}({self.channel.id}).")
async def stop(self):
"""Stops the currently playing track."""
self._current = None

View File

@@ -611,7 +611,10 @@ class NodePool:
"""
if identifier in cls._nodes.keys():
raise NodeCreationError(f"A node with identifier '{identifier}' already exists.")
if not logger:
logger = logging.getLogger("voicelink")
node = Node(
pool=cls, bot=bot, host=host, port=port, password=password,
identifier=identifier, secure=secure, heartbeat=heartbeat, spotify_client_id=spotify_client_id,