수정
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Connectors, LoadType, Shoukaku } from "shoukaku";
|
||||
import { Connectors, LoadType, Shoukaku, Track } from "shoukaku";
|
||||
import { Client } from "discord.js";
|
||||
import { GuildPlayer } from "./GuildPlayer";
|
||||
import { Config } from "../utils/Config";
|
||||
@@ -80,4 +80,14 @@ export class LavalinkManager {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public async youtubeSearch(query: string): Promise<Track[]> {
|
||||
const node = this.shoukaku.options.nodeResolver(this.shoukaku.nodes);
|
||||
if (!node) throw new ReferenceError(`[LavalinkManager] lavalink node is missing`);
|
||||
const result = await node.rest.resolve(`ytsearch:${query.trim()}`);
|
||||
// if (!result || result.loadType === LoadType.EMPTY || result.loadType === LoadType.ERROR) return [];
|
||||
if (result?.loadType === LoadType.TRACK) return [ result.data ];
|
||||
if (result?.loadType === LoadType.SEARCH) return result.data;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user