From 309d73d03da2b7d4f62e2e28e163b509b1b73313 Mon Sep 17 00:00:00 2001 From: Anri Kennel Date: Sun, 6 Aug 2023 19:31:08 +0200 Subject: [PATCH] Change default extractor (#97) Close #84 We use youtube for the search in `/play` BUT spotify is used for the autocompletion As always, either YoutubeSearch or SpotifySearch retrieve music from youtube Reviewed-on: https://git.mylloon.fr/ConfrerieDuKassoulait/Botanique/pulls/97 --- src/commands/music/play.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/commands/music/play.ts b/src/commands/music/play.ts index 42cbbb2..f867b61 100644 --- a/src/commands/music/play.ts +++ b/src/commands/music/play.ts @@ -10,7 +10,7 @@ import { import { Metadata } from "../../utils/metadata"; import { getLocale, getLocalizations } from "../../utils/locales"; import { getFilename } from "../../utils/misc"; -import { Player, SearchResult, useMasterPlayer, useQueue } from "discord-player"; +import { Player, QueryType, SearchResult, useMasterPlayer, useQueue } from "discord-player"; export default { scope: () => [], @@ -118,6 +118,7 @@ export default { const result = await player .search(query, { requestedBy: interaction.user, + searchEngine: QueryType.YOUTUBE_SEARCH, }) .then((x) => x); @@ -170,9 +171,14 @@ export default { }, 2900); }); - /* Create a race between a timeout and the research + /* Create a race between a timeout and the search * At the end, Discord will always receive a response */ - const tracks = await Promise.race([delay, player.search(query)]) + const tracks = await Promise.race([ + delay, + player.search(query, { + requestedBy: interaction.user, + }), + ]) .then((res) => { clearTimeout(timeoutId); return (res as SearchResult).tracks;