change all Player.guild to new Player._guild
This commit is contained in:
parent
980e9b5085
commit
01af4e9417
|
|
@ -41,7 +41,7 @@ class Player(VoiceProtocol):
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return (
|
return (
|
||||||
f"<Pomice.player bot={self.bot} guildId={self.guild.id} "
|
f"<Pomice.player bot={self.bot} guildId={self._guild.id} "
|
||||||
f"is_connected={self.is_connected} is_playing={self.is_playing}>"
|
f"is_connected={self.is_connected} is_playing={self.is_playing}>"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ class Player(VoiceProtocol):
|
||||||
|
|
||||||
await self.node.send(
|
await self.node.send(
|
||||||
op="voiceUpdate",
|
op="voiceUpdate",
|
||||||
guildId=str(self.guild.id),
|
guildId=str(self._guild.id),
|
||||||
**voice_data
|
**voice_data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -100,7 +100,7 @@ class Player(VoiceProtocol):
|
||||||
self._voice_state.clear()
|
self._voice_state.clear()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.channel = self.guild.get_channel(int(channel_id))
|
self.channel = self._guild.get_channel(int(channel_id))
|
||||||
await self._dispatch_voice_update({**self._voice_state, "event": data})
|
await self._dispatch_voice_update({**self._voice_state, "event": data})
|
||||||
|
|
||||||
async def _dispatch_event(self, data: dict):
|
async def _dispatch_event(self, data: dict):
|
||||||
|
|
@ -122,13 +122,13 @@ class Player(VoiceProtocol):
|
||||||
|
|
||||||
async def connect(self, *, timeout: float, reconnect: bool):
|
async def connect(self, *, timeout: float, reconnect: bool):
|
||||||
await self._guild.change_voice_state(channel=self.channel)
|
await self._guild.change_voice_state(channel=self.channel)
|
||||||
self._node._players[self.guild.id] = self
|
self._node._players[self._guild.id] = self
|
||||||
self.is_connected = True
|
self.is_connected = True
|
||||||
|
|
||||||
async def stop(self):
|
async def stop(self):
|
||||||
"""Stops a currently playing track."""
|
"""Stops a currently playing track."""
|
||||||
self.current = None
|
self.current = None
|
||||||
await self.node.send(op="stop", guildId=str(self.guild.id))
|
await self.node.send(op="stop", guildId=str(self._guild.id))
|
||||||
|
|
||||||
async def disconnect(self, *, force: bool = False):
|
async def disconnect(self, *, force: bool = False):
|
||||||
await self.stop()
|
await self.stop()
|
||||||
|
|
@ -136,12 +136,12 @@ class Player(VoiceProtocol):
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
self.channel = None
|
self.channel = None
|
||||||
self._is_connected = False
|
self._is_connected = False
|
||||||
del self._node._players[self.guild.id]
|
del self._node._players[self._guild.id]
|
||||||
|
|
||||||
async def destroy(self):
|
async def destroy(self):
|
||||||
"""Disconnects a player and destroys the player instance."""
|
"""Disconnects a player and destroys the player instance."""
|
||||||
await self.disconnect()
|
await self.disconnect()
|
||||||
await self._node.send(op="destroy", guildId=str(self.guild.id))
|
await self._node.send(op="destroy", guildId=str(self._guild.id))
|
||||||
|
|
||||||
async def play(self, track: objects.Track, start_position: int = 0) -> objects.Track:
|
async def play(self, track: objects.Track, start_position: int = 0) -> objects.Track:
|
||||||
"""Plays a track. If a Spotify track is passed in, it will be handled accordingly."""
|
"""Plays a track. If a Spotify track is passed in, it will be handled accordingly."""
|
||||||
|
|
@ -151,7 +151,7 @@ class Player(VoiceProtocol):
|
||||||
))[0]
|
))[0]
|
||||||
await self._node.send(
|
await self._node.send(
|
||||||
op="play",
|
op="play",
|
||||||
guildId=str(self.guild.id),
|
guildId=str(self._guild.id),
|
||||||
track=spotify_track.track_id,
|
track=spotify_track.track_id,
|
||||||
startTime=start_position,
|
startTime=start_position,
|
||||||
endTime=spotify_track.length,
|
endTime=spotify_track.length,
|
||||||
|
|
@ -160,7 +160,7 @@ class Player(VoiceProtocol):
|
||||||
else:
|
else:
|
||||||
await self._node.send(
|
await self._node.send(
|
||||||
op="play",
|
op="play",
|
||||||
guildId=str(self.guild.id),
|
guildId=str(self._guild.id),
|
||||||
track=track.track_id,
|
track=track.track_id,
|
||||||
startTime=start_position,
|
startTime=start_position,
|
||||||
endTime=track.length,
|
endTime=track.length,
|
||||||
|
|
@ -177,18 +177,18 @@ class Player(VoiceProtocol):
|
||||||
f"Seek position must be between 0 and the track length"
|
f"Seek position must be between 0 and the track length"
|
||||||
)
|
)
|
||||||
|
|
||||||
await self._node.send(op="seek", guildId=str(self.guild.id), position=position)
|
await self._node.send(op="seek", guildId=str(self._guild.id), position=position)
|
||||||
return self._position
|
return self._position
|
||||||
|
|
||||||
async def set_pause(self, pause: bool) -> bool:
|
async def set_pause(self, pause: bool) -> bool:
|
||||||
"""Sets the pause state of the currently playing track."""
|
"""Sets the pause state of the currently playing track."""
|
||||||
await self._node.send(op="pause", guildId=str(self.guild.id), pause=pause)
|
await self._node.send(op="pause", guildId=str(self._guild.id), pause=pause)
|
||||||
self._paused = pause
|
self._paused = pause
|
||||||
return self._paused
|
return self._paused
|
||||||
|
|
||||||
async def set_volume(self, volume: int) -> int:
|
async def set_volume(self, volume: int) -> int:
|
||||||
"""Sets the volume of the player as an integer. Lavalink accepts an amount from 0 to 500."""
|
"""Sets the volume of the player as an integer. Lavalink accepts an amount from 0 to 500."""
|
||||||
await self._node.send(op="volume", guildId=str(self.guild.id), volume=volume)
|
await self._node.send(op="volume", guildId=str(self._guild.id), volume=volume)
|
||||||
self._volume = volume
|
self._volume = volume
|
||||||
return self._volume
|
return self._volume
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ class Player(VoiceProtocol):
|
||||||
"""Sets a filter of the player. Takes a pomice.Filter object.
|
"""Sets a filter of the player. Takes a pomice.Filter object.
|
||||||
This will only work if you are using the development version of Lavalink.
|
This will only work if you are using the development version of Lavalink.
|
||||||
"""
|
"""
|
||||||
await self._node.send(op="filters", guildId=str(self.guild.id), **filter.payload)
|
await self._node.send(op="filters", guildId=str(self._guild.id), **filter.payload)
|
||||||
await self.seek(self.position)
|
await self.seek(self.position)
|
||||||
self._filter = filter
|
self._filter = filter
|
||||||
return filter
|
return filter
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue