change all Player.guild to new Player._guild

This commit is contained in:
vveeps 2021-10-07 18:27:17 +03:00
parent 980e9b5085
commit 01af4e9417
1 changed files with 13 additions and 13 deletions

View File

@ -41,7 +41,7 @@ class Player(VoiceProtocol):
def __repr__(self):
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}>"
)
@ -85,7 +85,7 @@ class Player(VoiceProtocol):
await self.node.send(
op="voiceUpdate",
guildId=str(self.guild.id),
guildId=str(self._guild.id),
**voice_data
)
@ -100,7 +100,7 @@ class Player(VoiceProtocol):
self._voice_state.clear()
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})
async def _dispatch_event(self, data: dict):
@ -122,13 +122,13 @@ class Player(VoiceProtocol):
async def connect(self, *, timeout: float, reconnect: bool):
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
async def stop(self):
"""Stops a currently playing track."""
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):
await self.stop()
@ -136,12 +136,12 @@ class Player(VoiceProtocol):
self.cleanup()
self.channel = None
self._is_connected = False
del self._node._players[self.guild.id]
del self._node._players[self._guild.id]
async def destroy(self):
"""Disconnects a player and destroys the player instance."""
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:
"""Plays a track. If a Spotify track is passed in, it will be handled accordingly."""
@ -151,7 +151,7 @@ class Player(VoiceProtocol):
))[0]
await self._node.send(
op="play",
guildId=str(self.guild.id),
guildId=str(self._guild.id),
track=spotify_track.track_id,
startTime=start_position,
endTime=spotify_track.length,
@ -160,7 +160,7 @@ class Player(VoiceProtocol):
else:
await self._node.send(
op="play",
guildId=str(self.guild.id),
guildId=str(self._guild.id),
track=track.track_id,
startTime=start_position,
endTime=track.length,
@ -177,18 +177,18 @@ class Player(VoiceProtocol):
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
async def set_pause(self, pause: bool) -> bool:
"""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
return self._paused
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."""
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
return self._volume
@ -196,7 +196,7 @@ class Player(VoiceProtocol):
"""Sets a filter of the player. Takes a pomice.Filter object.
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)
self._filter = filter
return filter