Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

Add support for the "local" lavaplayer source #169

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/structures/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ export interface Manager {
* @noInheritDoc
*/
export class Manager extends EventEmitter {
public static readonly DEFAULT_SOURCES: Record<SearchPlatform, string> = {
public static readonly DEFAULT_SOURCES: Partial<Record<SearchPlatform, string>> = {
"youtube music": "ytmsearch",
"youtube": "ytsearch",
"soundcloud": "scsearch"
"soundcloud": "scsearch",
}

/** The map of players. */
Expand Down Expand Up @@ -342,9 +342,9 @@ export class Manager extends EventEmitter {

const _query: SearchQuery = typeof query === "string" ? { query } : query;
const _source = Manager.DEFAULT_SOURCES[_query.source ?? this.options.defaultSearchPlatform] ?? _query.source;

let search = _query.query;
if (!/^https?:\/\//.test(search)) {
if (_source !== "local" && !/^(https?|file):\/\//.test(search)) {
search = `${_source}:${search}`;
}

Expand Down Expand Up @@ -546,7 +546,7 @@ export interface ManagerOptions {
send(id: string, payload: Payload): void;
}

export type SearchPlatform = "youtube" | "youtube music" | "soundcloud";
export type SearchPlatform = "youtube" | "youtube music" | "soundcloud" | "local";

export interface SearchQuery {
/** The source to search from. */
Expand Down