magmastream 2.9.0-dev.33 → 2.9.0-dev.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -266,6 +266,9 @@ declare enum ManagerEventTypes {
266
266
  ChapterStarted = "chapterStarted",
267
267
  ChaptersLoaded = "chaptersLoaded",
268
268
  Debug = "debug",
269
+ LyricsFoundEvent = "lyricsFoundEvent",
270
+ LyricsLineEvent = "lyricsLineEvent",
271
+ LyricsNotFoundEvent = "lyricsNotFoundEvent",
269
272
  NodeConnect = "nodeConnect",
270
273
  NodeCreate = "nodeCreate",
271
274
  NodeDestroy = "nodeDestroy",
@@ -808,6 +811,9 @@ interface ManagerEvents {
808
811
  [ManagerEventTypes.ChapterStarted]: [player: Player, track: Track, payload: SponsorBlockChapterStarted];
809
812
  [ManagerEventTypes.ChaptersLoaded]: [player: Player, track: Track, payload: SponsorBlockChaptersLoaded];
810
813
  [ManagerEventTypes.Debug]: [info: string];
814
+ [ManagerEventTypes.LyricsFoundEvent]: [player: Player, track: Track, payload: LyricsFoundEvent];
815
+ [ManagerEventTypes.LyricsLineEvent]: [player: Player, track: Track, payload: LyricsLineEvent];
816
+ [ManagerEventTypes.LyricsNotFoundEvent]: [player: Player, track: Track, payload: LyricsNotFoundEvent];
811
817
  [ManagerEventTypes.NodeConnect]: [node: Node];
812
818
  [ManagerEventTypes.NodeCreate]: [node: Node];
813
819
  [ManagerEventTypes.NodeDestroy]: [node: Node];
@@ -1178,6 +1184,31 @@ interface Lyrics {
1178
1184
  lines: LyricsLine[];
1179
1185
  plugin: object[];
1180
1186
  }
1187
+ /**
1188
+ * LyricsFoundEvent interface
1189
+ */
1190
+ interface LyricsFoundEvent extends PlayerEvent {
1191
+ type: "LyricsFoundEvent";
1192
+ guildId: string;
1193
+ lyrics: Lyrics;
1194
+ }
1195
+ /**
1196
+ * LyricsNotFoundEvent interface
1197
+ */
1198
+ interface LyricsNotFoundEvent extends PlayerEvent {
1199
+ type: "LyricsNotFoundEvent";
1200
+ guildId: string;
1201
+ }
1202
+ /**
1203
+ * LyricsLineEvent interface
1204
+ */
1205
+ interface LyricsLineEvent extends PlayerEvent {
1206
+ type: "LyricsLineEvent";
1207
+ guildId: string;
1208
+ lineIndex: number;
1209
+ line: LyricsLine;
1210
+ skipped: boolean;
1211
+ }
1181
1212
  /**
1182
1213
  * NodeLink Get Lyrics Multiple interface
1183
1214
  */
@@ -1363,7 +1394,7 @@ type TrackEndReason = keyof typeof TrackEndReasonTypes;
1363
1394
  /**
1364
1395
  * Player Event Type Enum type
1365
1396
  */
1366
- type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted";
1397
+ type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted" | "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent";
1367
1398
  /**
1368
1399
  * Severity Types Enum type
1369
1400
  */
@@ -1379,7 +1410,7 @@ type SponsorBlockSegmentEventType = "SegmentSkipped" | "SegmentsLoaded" | "Chapt
1379
1410
  /**
1380
1411
  * Player Events Enum type
1381
1412
  */
1382
- type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents;
1413
+ type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents | LyricsEvent;
1383
1414
  /**
1384
1415
  * Load Type Enum type
1385
1416
  */
@@ -1396,6 +1427,14 @@ type VoiceReceiverEvent = StartSpeakingEventVoiceReceiver | EndSpeakingEventVoic
1396
1427
  * Search Result Enum type
1397
1428
  */
1398
1429
  type SearchResult = TrackSearchResult | SearchSearchResult | PlaylistSearchResult | ErrorOrEmptySearchResult;
1430
+ /**
1431
+ * Lyrics Event Enum type
1432
+ */
1433
+ type LyricsEvent = LyricsFoundEvent | LyricsNotFoundEvent | LyricsLineEvent;
1434
+ /**
1435
+ * Lyrics Event Type Enum type
1436
+ */
1437
+ type LyricsEventType = "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent";
1399
1438
 
1400
1439
  declare class Node$1 {
1401
1440
  manager: Manager;
@@ -1622,14 +1661,32 @@ declare class Node$1 {
1622
1661
  queueEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
1623
1662
  /**
1624
1663
  * Fetches the lyrics of a track from the Lavalink node.
1625
- * This method uses the `lavalyrics-plugin` to fetch the lyrics.
1626
- * If the plugin is not available, it will throw a RangeError.
1664
+ *
1665
+ * If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics.
1666
+ *
1667
+ * Requires the `lavalyrics-plugin` to be present in the Lavalink node.
1668
+ * Requires the `lavasrc-plugin` or `java-lyrics-plugin` to be present in the Lavalink node.
1627
1669
  *
1628
1670
  * @param {Track} track - The track to fetch the lyrics for.
1629
1671
  * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
1630
1672
  * @returns {Promise<Lyrics | NodeLinkGetLyrics>} A promise that resolves with the lyrics data.
1631
1673
  */
1632
1674
  getLyrics(track: Track, skipTrackSource?: boolean): Promise<Lyrics | NodeLinkGetLyrics>;
1675
+ /**
1676
+ * Subscribes to lyrics for a player.
1677
+ * @param {string} guildId - The ID of the guild to subscribe to lyrics for.
1678
+ * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
1679
+ * @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
1680
+ * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
1681
+ */
1682
+ lyricsSubscribe(guildId: string, skipTrackSource?: boolean): Promise<unknown>;
1683
+ /**
1684
+ * Unsubscribes from lyrics for a player.
1685
+ * @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
1686
+ * @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
1687
+ * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
1688
+ */
1689
+ lyricsUnsubscribe(guildId: string): Promise<unknown>;
1633
1690
  /**
1634
1691
  * Handles the event when a track becomes stuck during playback.
1635
1692
  * Stops the current track and emits a `trackStuck` event.
@@ -1691,6 +1748,30 @@ declare class Node$1 {
1691
1748
  * @param {SponsorBlockChapterStarted} payload - The event payload containing additional data about the chapter started event.
1692
1749
  */
1693
1750
  private sponsorBlockChapterStarted;
1751
+ /**
1752
+ * Emitted when lyrics for a track are found.
1753
+ * The payload of the event will contain the lyrics.
1754
+ * @param {Player} player - The player associated with the lyrics.
1755
+ * @param {Track} track - The track associated with the lyrics.
1756
+ * @param {LyricsFoundEvent} payload - The event payload containing additional data about the lyrics found event.
1757
+ */
1758
+ private lyricsFound;
1759
+ /**
1760
+ * Emitted when lyrics for a track are not found.
1761
+ * The payload of the event will contain the track.
1762
+ * @param {Player} player - The player associated with the lyrics.
1763
+ * @param {Track} track - The track associated with the lyrics.
1764
+ * @param {LyricsNotFoundEvent} payload - The event payload containing additional data about the lyrics not found event.
1765
+ */
1766
+ private lyricsNotFound;
1767
+ /**
1768
+ * Emitted when a line of lyrics for a track is received.
1769
+ * The payload of the event will contain the lyrics line.
1770
+ * @param {Player} player - The player associated with the lyrics line.
1771
+ * @param {Track} track - The track associated with the lyrics line.
1772
+ * @param {LyricsLineEvent} payload - The event payload containing additional data about the lyrics line event.
1773
+ */
1774
+ private lyricsLine;
1694
1775
  /**
1695
1776
  * Fetches Lavalink node information.
1696
1777
  * @returns {Promise<LavalinkInfo>} A promise that resolves to the Lavalink node information.
@@ -2850,4 +2931,4 @@ declare class OceanicManager extends Manager {
2850
2931
  }
2851
2932
 
2852
2933
  export { AutoPlayPlatform, AutoPlayUtils, AvailableFilters, DetritusManager, DiscordJSManager, ErisManager, Filters, LoadTypes, Manager, ManagerEventTypes, Node$1 as Node, OceanicManager, Player, PlayerStateEventTypes, Plugin$1 as Plugin, Queue, Rest, SearchPlatform, SeverityTypes, SponsorBlockSegment, StateStorageType, StateTypes, Structure, TrackEndReasonTypes, TrackPartial, TrackSourceTypes, TrackUtils, UseNodeOptions };
2853
- export type { CPUStats, DiscordPacket, EndSpeakingEventVoiceReceiver, EndSpeakingEventVoiceReceiverData, EqualizerBand, ErrorOrEmptySearchResult, Exception, Extendable, FrameStats, IQueue, LavaPlayer, LavalinkInfo, LavalinkResponse, LoadType, Lyrics, LyricsLine, ManagerEvents, ManagerInitOptions, ManagerOptions, MemoryStats, NodeLinkGetLyrics, NodeLinkGetLyricsEmpty, NodeLinkGetLyricsError, NodeLinkGetLyricsMultiple, NodeLinkGetLyricsSingle, NodeMessage, NodeOptions, NodeStats, Payload, PlayOptions, PlayerEvent, PlayerEventType, PlayerEvents, PlayerOptions, PlayerStateUpdateEvent, PlayerUpdate, PlayerUpdateVoiceState, PlaylistData, PlaylistInfoData, PlaylistRawData, PlaylistSearchResult, RedisConfig, SearchQuery, SearchResult, SearchSearchResult, Severity, Sizes, SponsorBlockChapterStarted, SponsorBlockChaptersLoaded, SponsorBlockSegmentEventType, SponsorBlockSegmentEvents, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, StartSpeakingEventVoiceReceiver, StartSpeakingEventVoiceReceiverData, StateStorageOptions, Track, TrackData, TrackDataInfo, TrackEndEvent, TrackEndReason, TrackExceptionEvent, TrackPluginInfo, TrackSearchResult, TrackSourceName, TrackStartEvent, TrackStuckEvent, UseNodeOption, VoicePacket, VoiceReceiverEvent, VoiceServer, VoiceServerUpdate, VoiceState, WebSocketClosedEvent };
2934
+ export type { CPUStats, DiscordPacket, EndSpeakingEventVoiceReceiver, EndSpeakingEventVoiceReceiverData, EqualizerBand, ErrorOrEmptySearchResult, Exception, Extendable, FrameStats, IQueue, LavaPlayer, LavalinkInfo, LavalinkResponse, LoadType, Lyrics, LyricsEvent, LyricsEventType, LyricsFoundEvent, LyricsLine, LyricsLineEvent, LyricsNotFoundEvent, ManagerEvents, ManagerInitOptions, ManagerOptions, MemoryStats, NodeLinkGetLyrics, NodeLinkGetLyricsEmpty, NodeLinkGetLyricsError, NodeLinkGetLyricsMultiple, NodeLinkGetLyricsSingle, NodeMessage, NodeOptions, NodeStats, Payload, PlayOptions, PlayerEvent, PlayerEventType, PlayerEvents, PlayerOptions, PlayerStateUpdateEvent, PlayerUpdate, PlayerUpdateVoiceState, PlaylistData, PlaylistInfoData, PlaylistRawData, PlaylistSearchResult, RedisConfig, SearchQuery, SearchResult, SearchSearchResult, Severity, Sizes, SponsorBlockChapterStarted, SponsorBlockChaptersLoaded, SponsorBlockSegmentEventType, SponsorBlockSegmentEvents, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, StartSpeakingEventVoiceReceiver, StartSpeakingEventVoiceReceiverData, StateStorageOptions, Track, TrackData, TrackDataInfo, TrackEndEvent, TrackEndReason, TrackExceptionEvent, TrackPluginInfo, TrackSearchResult, TrackSourceName, TrackStartEvent, TrackStuckEvent, UseNodeOption, VoicePacket, VoiceReceiverEvent, VoiceServer, VoiceServerUpdate, VoiceState, WebSocketClosedEvent };
@@ -141,6 +141,9 @@ var ManagerEventTypes;
141
141
  ManagerEventTypes["ChapterStarted"] = "chapterStarted";
142
142
  ManagerEventTypes["ChaptersLoaded"] = "chaptersLoaded";
143
143
  ManagerEventTypes["Debug"] = "debug";
144
+ ManagerEventTypes["LyricsFoundEvent"] = "lyricsFoundEvent";
145
+ ManagerEventTypes["LyricsLineEvent"] = "lyricsLineEvent";
146
+ ManagerEventTypes["LyricsNotFoundEvent"] = "lyricsNotFoundEvent";
144
147
  ManagerEventTypes["NodeConnect"] = "nodeConnect";
145
148
  ManagerEventTypes["NodeCreate"] = "nodeCreate";
146
149
  ManagerEventTypes["NodeDestroy"] = "nodeDestroy";
@@ -485,6 +485,15 @@ class Node {
485
485
  case "ChapterStarted":
486
486
  this.sponsorBlockChapterStarted(player, track, payload);
487
487
  break;
488
+ case "LyricsFoundEvent":
489
+ this.lyricsFound(player, track, payload);
490
+ break;
491
+ case "LyricsNotFoundEvent":
492
+ this.lyricsNotFound(player, track, payload);
493
+ break;
494
+ case "LyricsLineEvent":
495
+ this.lyricsLine(player, track, payload);
496
+ break;
488
497
  default:
489
498
  error = new Error(`Node#event unknown event '${type}'.`);
490
499
  this.manager.emit(Enums_1.ManagerEventTypes.NodeError, this, error);
@@ -734,19 +743,28 @@ class Node {
734
743
  }
735
744
  /**
736
745
  * Fetches the lyrics of a track from the Lavalink node.
737
- * This method uses the `lavalyrics-plugin` to fetch the lyrics.
738
- * If the plugin is not available, it will throw a RangeError.
746
+ *
747
+ * If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics.
748
+ *
749
+ * Requires the `lavalyrics-plugin` to be present in the Lavalink node.
750
+ * Requires the `lavasrc-plugin` or `java-lyrics-plugin` to be present in the Lavalink node.
739
751
  *
740
752
  * @param {Track} track - The track to fetch the lyrics for.
741
753
  * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
742
754
  * @returns {Promise<Lyrics | NodeLinkGetLyrics>} A promise that resolves with the lyrics data.
743
755
  */
744
756
  async getLyrics(track, skipTrackSource = false) {
757
+ if (!this.connected)
758
+ throw new RangeError(`The node is not connected to the lavalink server: ${this.options.identifier}`);
745
759
  if (this.isNodeLink) {
746
760
  return (await this.rest.get(`/v4/lyrics?track=${encodeURIComponent(track.track)}&skipTrackSource=${skipTrackSource}`));
747
761
  }
748
- if (!this.info.plugins.some((plugin) => plugin.name === "lavalyrics-plugin"))
749
- throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node: ${this.options.identifier}`);
762
+ if (!this.info.plugins.some((plugin) => plugin.name === "lavalyrics-plugin")) {
763
+ throw new RangeError(`The plugin "lavalyrics-plugin" must be present in the lavalink node: ${this.options.identifier}`);
764
+ }
765
+ if (!this.info.plugins.some((plugin) => plugin.name === "lavasrc-plugin" || plugin.name === "java-lyrics-plugin")) {
766
+ throw new RangeError(`One of the following plugins must also be present in the lavalink node: "lavasrc-plugin" or "java-lyrics-plugin" (Node: ${this.options.identifier})`);
767
+ }
750
768
  return ((await this.rest.get(`/v4/lyrics?track=${encodeURIComponent(track.track)}&skipTrackSource=${skipTrackSource}`)) || {
751
769
  source: null,
752
770
  provider: null,
@@ -755,6 +773,42 @@ class Node {
755
773
  plugin: [],
756
774
  });
757
775
  }
776
+ /**
777
+ * Subscribes to lyrics for a player.
778
+ * @param {string} guildId - The ID of the guild to subscribe to lyrics for.
779
+ * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
780
+ * @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
781
+ * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
782
+ */
783
+ async lyricsSubscribe(guildId, skipTrackSource = false) {
784
+ if (!this.connected)
785
+ throw new RangeError(`The node is not connected to the lavalink server: ${this.options.identifier}`);
786
+ if (this.isNodeLink)
787
+ throw new RangeError(`The node is a node link: ${this.options.identifier}`);
788
+ if (!this.info.plugins.some((plugin) => plugin.name === "lavalyrics-plugin")) {
789
+ throw new RangeError(`The plugin "lavalyrics-plugin" must be present in the lavalink node: ${this.options.identifier}`);
790
+ }
791
+ if (!this.info.plugins.some((plugin) => plugin.name === "lavasrc-plugin" || plugin.name === "java-lyrics-plugin")) {
792
+ throw new RangeError(`One of the following plugins must also be present in the lavalink node: "lavasrc-plugin" or "java-lyrics-plugin" (Node: ${this.options.identifier})`);
793
+ }
794
+ return await this.rest.post(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe?skipTrackSource=${skipTrackSource}`, {});
795
+ }
796
+ /**
797
+ * Unsubscribes from lyrics for a player.
798
+ * @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
799
+ * @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
800
+ * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
801
+ */
802
+ async lyricsUnsubscribe(guildId) {
803
+ if (!this.connected)
804
+ throw new RangeError(`The node is not connected to the lavalink server: ${this.options.identifier}`);
805
+ if (this.isNodeLink)
806
+ throw new RangeError(`The node is a node link: ${this.options.identifier}`);
807
+ if (!this.info.plugins.some((plugin) => plugin.name === "java-lyrics-plugin")) {
808
+ throw new RangeError(`there is no java-lyrics-plugin available in the lavalink node: ${this.options.identifier}`);
809
+ }
810
+ return await this.rest.delete(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`);
811
+ }
758
812
  /**
759
813
  * Handles the event when a track becomes stuck during playback.
760
814
  * Stops the current track and emits a `trackStuck` event.
@@ -833,6 +887,36 @@ class Node {
833
887
  sponsorBlockChapterStarted(player, track, payload) {
834
888
  return this.manager.emit(Enums_1.ManagerEventTypes.ChapterStarted, player, track, payload);
835
889
  }
890
+ /**
891
+ * Emitted when lyrics for a track are found.
892
+ * The payload of the event will contain the lyrics.
893
+ * @param {Player} player - The player associated with the lyrics.
894
+ * @param {Track} track - The track associated with the lyrics.
895
+ * @param {LyricsFoundEvent} payload - The event payload containing additional data about the lyrics found event.
896
+ */
897
+ lyricsFound(player, track, payload) {
898
+ return this.manager.emit(Enums_1.ManagerEventTypes.LyricsFoundEvent, player, track, payload);
899
+ }
900
+ /**
901
+ * Emitted when lyrics for a track are not found.
902
+ * The payload of the event will contain the track.
903
+ * @param {Player} player - The player associated with the lyrics.
904
+ * @param {Track} track - The track associated with the lyrics.
905
+ * @param {LyricsNotFoundEvent} payload - The event payload containing additional data about the lyrics not found event.
906
+ */
907
+ lyricsNotFound(player, track, payload) {
908
+ return this.manager.emit(Enums_1.ManagerEventTypes.LyricsNotFoundEvent, player, track, payload);
909
+ }
910
+ /**
911
+ * Emitted when a line of lyrics for a track is received.
912
+ * The payload of the event will contain the lyrics line.
913
+ * @param {Player} player - The player associated with the lyrics line.
914
+ * @param {Track} track - The track associated with the lyrics line.
915
+ * @param {LyricsLineEvent} payload - The event payload containing additional data about the lyrics line event.
916
+ */
917
+ lyricsLine(player, track, payload) {
918
+ return this.manager.emit(Enums_1.ManagerEventTypes.LyricsLineEvent, player, track, payload);
919
+ }
836
920
  /**
837
921
  * Fetches Lavalink node information.
838
922
  * @returns {Promise<LavalinkInfo>} A promise that resolves to the Lavalink node information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.9.0-dev.33",
3
+ "version": "2.9.0-dev.34",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",