lavalink-client 2.1.0 → 2.1.2

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/README.md CHANGED
@@ -202,4 +202,9 @@ Most features of this update got tested, but if you encounter any bugs feel free
202
202
  - `player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass(boostFactor:number, cutoffFrequency:number)`
203
203
  - and for: `player.filterManager.lavalinkFilterPlugin`
204
204
  - `player.filterManager.lavalinkFilterPlugin.toggleEcho(delay:number, decay:number)`
205
- - `player.filterManager.lavalinkFilterPlugin.toggleReverb(delays:number[], gains:number[])`
205
+ - `player.filterManager.lavalinkFilterPlugin.toggleReverb(delays:number[], gains:number[])`
206
+
207
+ ## **Version 2.1.1**
208
+ - Enforce link searches for users with following searchPlatform Options: "http" | "https" | "link" | "uri"
209
+ - Additionally strongend the code behind that
210
+ - Added searchPlatform for local tracks (aka files on the lavalink server...): "local"
@@ -173,7 +173,7 @@ export interface LavalinkManager {
173
173
  emit<U extends keyof LavalinkManagerEvents>(event: U, ...args: Parameters<LavalinkManagerEvents[U]>): boolean;
174
174
  }
175
175
  export declare class LavalinkManager extends EventEmitter {
176
- static DefaultSources: Record<SearchPlatform, import("./Utils").LavalinkSearchPlatform>;
176
+ static DefaultSources: Record<SearchPlatform, import("./Utils").LavalinkSearchPlatform | import("./Utils").ClientCustomSearchPlatformUtils>;
177
177
  static SourceLinksRegexes: Record<import("./Utils").SourcesRegex, RegExp>;
178
178
  initiated: boolean;
179
179
  readonly players: MiniMap<string, Player>;
@@ -1,5 +1,5 @@
1
- import { LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
2
- export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform>;
1
+ import { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
2
+ export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform | ClientCustomSearchPlatformUtils>;
3
3
  export declare const LavalinkPlugins: {
4
4
  DuncteBot_Plugin: string;
5
5
  LavaSrc: string;
@@ -47,10 +47,20 @@ exports.DefaultSources = {
47
47
  "speak": "speak",
48
48
  "tts": "tts",
49
49
  "ftts": "ftts",
50
+ "flowery": "ftts",
51
+ "flowery.tts": "ftts",
52
+ "flowerytts": "ftts",
50
53
  // Client sided search platforms
51
54
  "bandcamp": "bcsearch",
52
55
  "bc": "bcsearch",
53
56
  "bcsearch": "bcsearch",
57
+ // local files
58
+ "local": "local",
59
+ // http requests
60
+ "http": "http",
61
+ "https": "https",
62
+ "link": "link",
63
+ "uri": "uri"
54
64
  };
55
65
  exports.LavalinkPlugins = {
56
66
  DuncteBot_Plugin: "DuncteBot-plugin",
@@ -124,12 +124,17 @@ class LavalinkNode {
124
124
  throw new Error("Bandcamp Search only works on the player!");
125
125
  }
126
126
  let uri = `/loadtracks?identifier=`;
127
- if (!/^https?:\/\//.test(Query.query))
128
- uri += `${Query.source}:`;
129
- if (Query.source === "ftts")
130
- uri += `//${encodeURIComponent(encodeURI(decodeURIComponent(Query.query)))}`;
131
- else
127
+ if (/^https?:\/\//.test(Query.query) || ["http", "https", "link", "uri"].includes(Query.source)) { // if it's a link simply encode it
132
128
  uri += encodeURIComponent(decodeURIComponent(Query.query));
129
+ }
130
+ else { // if not make a query out of it
131
+ if (Query.source !== "local")
132
+ uri += `${Query.source}:`; // only add the query source string if it's not a local track
133
+ if (Query.source === "ftts")
134
+ uri += `//${encodeURIComponent(encodeURI(decodeURIComponent(Query.query)))}`;
135
+ else
136
+ uri += encodeURIComponent(decodeURIComponent(Query.query));
137
+ }
133
138
  const res = await this.request(uri);
134
139
  // transform the data which can be Error, Track or Track[] to enfore [Track]
135
140
  const resTracks = res.loadType === "playlist" ? res.data?.tracks : res.loadType === "track" ? [res.data] : res.loadType === "search" ? Array.isArray(res.data) ? res.data : [res.data] : [];
@@ -18,7 +18,9 @@ export type DuncteSearchPlatform = "speak" | "tts";
18
18
  export type LavalinkClientSearchPlatform = "bcsearch";
19
19
  export type LavalinkClientSearchPlatformResolve = "bandcamp" | "bc";
20
20
  export type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | LavalinkClientSearchPlatform;
21
- export type ClientSearchPlatform = "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
21
+ export type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
22
+ export type ClientSearchPlatform = ClientCustomSearchPlatformUtils | // for file/link requests
23
+ "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | "flowerytts" | "flowery" | "flowery.tts" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
22
24
  export type SearchPlatform = LavalinkSearchPlatform | ClientSearchPlatform;
23
25
  export type SourcesRegex = "YoutubeRegex" | "YoutubeMusicRegex" | "SoundCloudRegex" | "SoundCloudMobileRegex" | "DeezerTrackRegex" | "DeezerArtistRegex" | "DeezerEpisodeRegex" | "DeezerMixesRegex" | "DeezerPageLinkRegex" | "DeezerPlaylistRegex" | "DeezerAlbumRegex" | "AllDeezerRegex" | "AllDeezerRegexWithoutPageLink" | "SpotifySongRegex" | "SpotifyPlaylistRegex" | "SpotifyArtistRegex" | "SpotifyEpisodeRegex" | "SpotifyShowRegex" | "SpotifyAlbumRegex" | "AllSpotifyRegex" | "mp3Url" | "m3uUrl" | "m3u8Url" | "mp4Url" | "m4aUrl" | "wavUrl" | "aacpUrl" | "tiktok" | "mixcloud" | "musicYandex" | "radiohost" | "bandcamp" | "appleMusic" | "TwitchTv" | "vimeo";
24
26
  export interface PlaylistInfo {
@@ -173,7 +173,7 @@ export interface LavalinkManager {
173
173
  emit<U extends keyof LavalinkManagerEvents>(event: U, ...args: Parameters<LavalinkManagerEvents[U]>): boolean;
174
174
  }
175
175
  export declare class LavalinkManager extends EventEmitter {
176
- static DefaultSources: Record<SearchPlatform, import("./Utils").LavalinkSearchPlatform>;
176
+ static DefaultSources: Record<SearchPlatform, import("./Utils").LavalinkSearchPlatform | import("./Utils").ClientCustomSearchPlatformUtils>;
177
177
  static SourceLinksRegexes: Record<import("./Utils").SourcesRegex, RegExp>;
178
178
  initiated: boolean;
179
179
  readonly players: MiniMap<string, Player>;
@@ -1,5 +1,5 @@
1
- import { LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
2
- export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform>;
1
+ import { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
2
+ export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform | ClientCustomSearchPlatformUtils>;
3
3
  export declare const LavalinkPlugins: {
4
4
  DuncteBot_Plugin: string;
5
5
  LavaSrc: string;
@@ -44,10 +44,20 @@ export const DefaultSources = {
44
44
  "speak": "speak",
45
45
  "tts": "tts",
46
46
  "ftts": "ftts",
47
+ "flowery": "ftts",
48
+ "flowery.tts": "ftts",
49
+ "flowerytts": "ftts",
47
50
  // Client sided search platforms
48
51
  "bandcamp": "bcsearch",
49
52
  "bc": "bcsearch",
50
53
  "bcsearch": "bcsearch",
54
+ // local files
55
+ "local": "local",
56
+ // http requests
57
+ "http": "http",
58
+ "https": "https",
59
+ "link": "link",
60
+ "uri": "uri"
51
61
  };
52
62
  export const LavalinkPlugins = {
53
63
  DuncteBot_Plugin: "DuncteBot-plugin",
@@ -120,12 +120,17 @@ export class LavalinkNode {
120
120
  throw new Error("Bandcamp Search only works on the player!");
121
121
  }
122
122
  let uri = `/loadtracks?identifier=`;
123
- if (!/^https?:\/\//.test(Query.query))
124
- uri += `${Query.source}:`;
125
- if (Query.source === "ftts")
126
- uri += `//${encodeURIComponent(encodeURI(decodeURIComponent(Query.query)))}`;
127
- else
123
+ if (/^https?:\/\//.test(Query.query) || ["http", "https", "link", "uri"].includes(Query.source)) { // if it's a link simply encode it
128
124
  uri += encodeURIComponent(decodeURIComponent(Query.query));
125
+ }
126
+ else { // if not make a query out of it
127
+ if (Query.source !== "local")
128
+ uri += `${Query.source}:`; // only add the query source string if it's not a local track
129
+ if (Query.source === "ftts")
130
+ uri += `//${encodeURIComponent(encodeURI(decodeURIComponent(Query.query)))}`;
131
+ else
132
+ uri += encodeURIComponent(decodeURIComponent(Query.query));
133
+ }
129
134
  const res = await this.request(uri);
130
135
  // transform the data which can be Error, Track or Track[] to enfore [Track]
131
136
  const resTracks = res.loadType === "playlist" ? res.data?.tracks : res.loadType === "track" ? [res.data] : res.loadType === "search" ? Array.isArray(res.data) ? res.data : [res.data] : [];
@@ -18,7 +18,9 @@ export type DuncteSearchPlatform = "speak" | "tts";
18
18
  export type LavalinkClientSearchPlatform = "bcsearch";
19
19
  export type LavalinkClientSearchPlatformResolve = "bandcamp" | "bc";
20
20
  export type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | LavalinkClientSearchPlatform;
21
- export type ClientSearchPlatform = "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
21
+ export type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
22
+ export type ClientSearchPlatform = ClientCustomSearchPlatformUtils | // for file/link requests
23
+ "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | "flowerytts" | "flowery" | "flowery.tts" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
22
24
  export type SearchPlatform = LavalinkSearchPlatform | ClientSearchPlatform;
23
25
  export type SourcesRegex = "YoutubeRegex" | "YoutubeMusicRegex" | "SoundCloudRegex" | "SoundCloudMobileRegex" | "DeezerTrackRegex" | "DeezerArtistRegex" | "DeezerEpisodeRegex" | "DeezerMixesRegex" | "DeezerPageLinkRegex" | "DeezerPlaylistRegex" | "DeezerAlbumRegex" | "AllDeezerRegex" | "AllDeezerRegexWithoutPageLink" | "SpotifySongRegex" | "SpotifyPlaylistRegex" | "SpotifyArtistRegex" | "SpotifyEpisodeRegex" | "SpotifyShowRegex" | "SpotifyAlbumRegex" | "AllSpotifyRegex" | "mp3Url" | "m3uUrl" | "m3u8Url" | "mp4Url" | "m4aUrl" | "wavUrl" | "aacpUrl" | "tiktok" | "mixcloud" | "musicYandex" | "radiohost" | "bandcamp" | "appleMusic" | "TwitchTv" | "vimeo";
24
26
  export interface PlaylistInfo {
@@ -173,7 +173,7 @@ export interface LavalinkManager {
173
173
  emit<U extends keyof LavalinkManagerEvents>(event: U, ...args: Parameters<LavalinkManagerEvents[U]>): boolean;
174
174
  }
175
175
  export declare class LavalinkManager extends EventEmitter {
176
- static DefaultSources: Record<SearchPlatform, import("./Utils").LavalinkSearchPlatform>;
176
+ static DefaultSources: Record<SearchPlatform, import("./Utils").LavalinkSearchPlatform | import("./Utils").ClientCustomSearchPlatformUtils>;
177
177
  static SourceLinksRegexes: Record<import("./Utils").SourcesRegex, RegExp>;
178
178
  initiated: boolean;
179
179
  readonly players: MiniMap<string, Player>;
@@ -1,5 +1,5 @@
1
- import { LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
2
- export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform>;
1
+ import { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
2
+ export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform | ClientCustomSearchPlatformUtils>;
3
3
  export declare const LavalinkPlugins: {
4
4
  DuncteBot_Plugin: string;
5
5
  LavaSrc: string;
@@ -18,7 +18,9 @@ export type DuncteSearchPlatform = "speak" | "tts";
18
18
  export type LavalinkClientSearchPlatform = "bcsearch";
19
19
  export type LavalinkClientSearchPlatformResolve = "bandcamp" | "bc";
20
20
  export type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | LavalinkClientSearchPlatform;
21
- export type ClientSearchPlatform = "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
21
+ export type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
22
+ export type ClientSearchPlatform = ClientCustomSearchPlatformUtils | // for file/link requests
23
+ "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | "flowerytts" | "flowery" | "flowery.tts" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
22
24
  export type SearchPlatform = LavalinkSearchPlatform | ClientSearchPlatform;
23
25
  export type SourcesRegex = "YoutubeRegex" | "YoutubeMusicRegex" | "SoundCloudRegex" | "SoundCloudMobileRegex" | "DeezerTrackRegex" | "DeezerArtistRegex" | "DeezerEpisodeRegex" | "DeezerMixesRegex" | "DeezerPageLinkRegex" | "DeezerPlaylistRegex" | "DeezerAlbumRegex" | "AllDeezerRegex" | "AllDeezerRegexWithoutPageLink" | "SpotifySongRegex" | "SpotifyPlaylistRegex" | "SpotifyArtistRegex" | "SpotifyEpisodeRegex" | "SpotifyShowRegex" | "SpotifyAlbumRegex" | "AllSpotifyRegex" | "mp3Url" | "m3uUrl" | "m3u8Url" | "mp4Url" | "m4aUrl" | "wavUrl" | "aacpUrl" | "tiktok" | "mixcloud" | "musicYandex" | "radiohost" | "bandcamp" | "appleMusic" | "TwitchTv" | "vimeo";
24
26
  export interface PlaylistInfo {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lavalink-client",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",