diff --git a/src/structures/ShoukakuEvents.js b/src/structures/ShoukakuEvents.js index ae98612..c50a57d 100644 --- a/src/structures/ShoukakuEvents.js +++ b/src/structures/ShoukakuEvents.js @@ -212,19 +212,22 @@ class MusicPlayer { if (!node) throw new Error('No available Lavalink nodes!'); try { - // Determine search type - let searchOptions = {}; + // Determine search type and prepare the identifier string + let identifier; if (query.startsWith('http')) { // Direct URL - searchOptions = { query }; + identifier = query; } else { - // Search with prefix - searchOptions = { query: `ytsearch:${query}` }; + // Search with prefix (Lavalink handles ytsearch/ytmsearch automatically with the plugin) + // identifier = `ytsearch:${query}`; // Prefix might not be needed with the plugin, let Lavalink decide + identifier = query; // Pass the raw query for non-URLs } - // Perform the search - const result = await node.rest.resolve(searchOptions); + // Perform the search using the identifier string + const result = await node.rest.resolve(identifier); if (!result || result.loadType === 'error' || result.loadType === 'empty') { + // Log the identifier for debugging if search fails + logger.debug(`Search failed for identifier: ${identifier}`); throw new Error(result?.exception?.message || 'No results found'); } @@ -278,4 +281,4 @@ module.exports = { return musicPlayer; }, musicPlayer -}; \ No newline at end of file +};