Skip to content

Commit

Permalink
Added TrackStart event and TYPE_CHECKING.
Browse files Browse the repository at this point in the history
This commit bumps Wavelinks' minimum required Python version to 3.7+.
  • Loading branch information
EvieePy committed Feb 3, 2020
1 parent 9d99f8b commit 8a2e7d2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
25 changes: 22 additions & 3 deletions wavelink/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from .player import Player
from .player import Track
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .player import Player
from .player import Track


__all__ = ('WavelinkEvent', 'TrackEnd', 'TrackException', 'TrackStuck')
__all__ = ('WavelinkEvent', 'TrackEnd', 'TrackException', 'TrackStuck', 'TrackStart')


class WavelinkEvent:
Expand Down Expand Up @@ -89,3 +92,19 @@ def __init__(self, player: Player, track: Track, threshold: int):

def __str__(self):
return 'TrackStuck'


class TrackStart(WavelinkEvent):
"""Event dispatched on TrackStart.
:ivar player: The :class:`wavelink.player.Player` associated with the event.
:ivar track: The :class:`wavelink.player.Track` associated with the event.
"""

__slots__ = ()

def __init__(self, player: Player, track: Track):
super().__init__(player, track)

def __str__(self):
return 'TrackStart'
3 changes: 3 additions & 0 deletions wavelink/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from .errors import *
from .eqs import *
from .events import TrackStart


__log__ = logging.getLogger(__name__)
Expand Down Expand Up @@ -243,6 +244,8 @@ async def play(self, track: Track, *, replace: bool = True, start: int = 0, end:
payload['endTime'] = str(end)

await self.node._send(**payload)
self.bot.loop.create_task(self.node.on_event(TrackStart(player=self, track=track)))

__log__.debug(f'PLAYER | Started playing track:: {str(track)} ({self.channel_id})')

async def stop(self):
Expand Down

0 comments on commit 8a2e7d2

Please sign in to comment.