-
Notifications
You must be signed in to change notification settings - Fork 9
feat(events): add LavaLyrics events #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
f25887c
3cd5888
08908b6
f66e6bb
c96a271
d9f451e
26d28f1
3f96106
80d1e7e
d4824e7
1d6d3c7
53b3328
8187b84
1ec7edc
17ccebe
db2f4ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,9 @@ | |||||
| "TrackStartEvent", | ||||||
| "TrackStuckEvent", | ||||||
| "WebSocketClosedEvent", | ||||||
| "LyricsLineEvent", | ||||||
| "LyricsFoundEvent", | ||||||
| "LyricsNotFoundEvent", | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -89,6 +92,69 @@ def __repr__(self) -> str: | |||||
| ) | ||||||
|
|
||||||
|
|
||||||
| class LyricsLineEvent(Generic[PlayerT]): | ||||||
| """Represents a lyrics line event. | ||||||
|
|
||||||
| Attributes | ||||||
| ---------- | ||||||
| guildId: :class:`str` | ||||||
| The guild ID that received the lyrics line. | ||||||
| line: :class:`dict` | ||||||
| Information about the lyrics line. | ||||||
| """ | ||||||
|
|
||||||
| __slots__ = ("guildId", "line") | ||||||
|
|
||||||
| def __init__(self, *, guildId: str, line: dict) -> None: | ||||||
| self.guildId: str = guildId | ||||||
| self.line: dict = line | ||||||
|
|
||||||
| def __repr__(self) -> str: | ||||||
| """Get a string representation of the event.""" | ||||||
| return f"<LyricsLineEvent guildId={self.guildId} line={self.line!r}>" | ||||||
|
|
||||||
|
|
||||||
| class LyricsFoundEvent(Generic[PlayerT]): | ||||||
| """Represents a lyrics found event. | ||||||
|
|
||||||
| Attributes | ||||||
| ---------- | ||||||
| guildId: :class:`str` | ||||||
| The guild ID that received lyrics. | ||||||
| lyrics: :class:`dict` | ||||||
| Information about all lyrics, including provider and platform. | ||||||
| """ | ||||||
|
|
||||||
| __slots__ = ("guildId", "lyrics") | ||||||
|
|
||||||
| def __init__(self, *, guildId: str, lyrics: dict) -> None: | ||||||
| self.guildId: str = guildId | ||||||
| self.lyrics: dict = lyrics | ||||||
|
|
||||||
| def __repr__(self) -> str: | ||||||
| """Get a string representation of the event.""" | ||||||
| return f"<LyricsFoundEvent guildId={self.guildId} lyrics={self.lyrics!r}>" | ||||||
|
|
||||||
|
|
||||||
| class LyricsNotFoundEvent(Generic[PlayerT]): | ||||||
| """Represents a lyrics not found event. | ||||||
|
|
||||||
| Attributes | ||||||
| ---------- | ||||||
| guildId: :class:`str` | ||||||
| The guild ID that received event. | ||||||
| """ | ||||||
|
|
||||||
| __slots__ = "guildId" | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| def __init__(self, *, guildId: str) -> None: | ||||||
| self.guildId: str = guildId | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe a better solution is to continue to use the |
||||||
|
|
||||||
| def __repr__(self) -> str: | ||||||
| """Get a string representation of the event.""" | ||||||
| return f"<LyricsNotFoundEvent guildId={self.guildId}>" | ||||||
|
|
||||||
|
|
||||||
| class TrackStartEvent(Generic[PlayerT]): | ||||||
| """Represents an event when a track starts playing. | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1397,3 +1397,21 @@ async def sync_players( | |||||||||||||||
| for player_id in expected_player_ids - actual_player_ids | ||||||||||||||||
| ), | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| async def subscribe_to_lyrics(self, guild_id: int, skip_track_source: bool) -> None: | ||||||||||||||||
| """ | ||||||||||||||||
| Subscribe to Lyrics events. Requires Lavalyrics plugin to be installed. | ||||||||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| Parameters | ||||||||||||||||
| ---------- | ||||||||||||||||
| guild_id: | ||||||||||||||||
| The guild that will receive lyrics events | ||||||||||||||||
| skip_track_source: | ||||||||||||||||
| Skip the current track source and fetch from highest priority source | ||||||||||||||||
| """ | ||||||||||||||||
| data = await self.__request( | ||||||||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be no data here as it returns |
||||||||||||||||
| "POST", | ||||||||||||||||
| f"sessions/{self._session_id}/players/{guild_id}/lyrics/subscribe", | ||||||||||||||||
| params={"skipTrackSource": str(skip_track_source)}, | ||||||||||||||||
| ) | ||||||||||||||||
| _log.debug("Subscribe data: %s", data) | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this
dictinstead be aTypedDictcontaining the fields (timestamp,duration, etc) as with the other events here. Same with the other events you've added.