added player.is_dead, changed destroy
This commit is contained in:
parent
4e80283e21
commit
86fc4fbaf1
|
|
@ -150,6 +150,14 @@ class Player(VoiceProtocol):
|
|||
"""Property which returns the bot associated with this player instance"""
|
||||
return self._bot
|
||||
|
||||
@property
|
||||
def is_dead(self) -> bool:
|
||||
"""Returns a bool representing whether the player is dead or not.
|
||||
A player is considered dead if it has been destroyed and removed from stored players.
|
||||
"""
|
||||
return self._guild.id not in self._node._players
|
||||
|
||||
|
||||
async def _update_state(self, data: dict):
|
||||
state: dict = data.get("state")
|
||||
self._last_update = time.time() * 1000
|
||||
|
|
@ -240,11 +248,10 @@ class Player(VoiceProtocol):
|
|||
except AttributeError:
|
||||
# 'NoneType' has no attribute '_get_voice_client_key' raised by self.cleanup() ->
|
||||
# assume we're already disconnected and cleaned up
|
||||
assert self.channel is None \
|
||||
and not self.is_connected \
|
||||
and self.guild.id not in self._node._players
|
||||
assert self.channel is None and not self.is_connected
|
||||
|
||||
await self._node.send(op="destroy", guildId=str(self.guild.id))
|
||||
self._node._players.pop(self._guild.id)
|
||||
await self._node.send(op="destroy", guildId=str(self._guild.id))
|
||||
|
||||
async def play(self, track: Track, *, start_position: int = 0) -> Track:
|
||||
"""Plays a track. If a Spotify track is passed in, it will be handled accordingly."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue