improve play command payloads a bit (+ run autoformatting)

This commit is contained in:
vveeps 2021-10-26 15:32:08 +03:00
parent 2aca3a8d3a
commit 12544691eb
1 changed files with 18 additions and 19 deletions

View File

@ -29,9 +29,10 @@ class Player(VoiceProtocol):
await ctx.author.voice.channel.connect(cls=pomice.Player) await ctx.author.voice.channel.connect(cls=pomice.Player)
``` ```
""" """
def __call__(self, client: ClientType, channel: VoiceChannel): def __call__(self, client: ClientType, channel: VoiceChannel):
self.client: ClientType = client self.client: ClientType = client
self.channel : VoiceChannel = channel self.channel: VoiceChannel = channel
return self return self
@ -213,7 +214,8 @@ class Player(VoiceProtocol):
self, self,
track: Track, track: Track,
*, *,
start_position: int = 0, start: int = 0,
end: int = 0,
ignore_if_playing: bool = False ignore_if_playing: bool = False
) -> Track: ) -> 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."""
@ -223,24 +225,21 @@ class Player(VoiceProtocol):
ctx=track.ctx ctx=track.ctx
))[0] ))[0]
track.original = search track.original = search
track = search
data = {
"op": "play",
"guildId": str(self.guild.id),
"track": track.track_id,
"startTime": str(start),
"noReplace": ignore_if_playing
}
if end > 0:
data["endtime"] = str(end)
await self._node.send(**data)
await self._node.send(
op="play",
guildId=str(self.guild.id),
track=search.track_id,
startTime=start_position,
endTime=search.length,
noReplace=ignore_if_playing
)
else:
await self._node.send(
op="play",
guildId=str(self.guild.id),
track=track.track_id,
startTime=start_position,
endTime=track.length,
noReplace=ignore_if_playing
)
self._current = track self._current = track
return self._current return self._current