Change default extractor (#97)
Some checks failed
ci/woodpecker/push/publish Pipeline failed

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: #97
This commit is contained in:
Mylloon 2023-08-06 19:31:08 +02:00
parent fe97d264fc
commit 309d73d03d
Signed by: Forgejo
GPG key ID: E72245C752A07631

View file

@ -10,7 +10,7 @@ import {
import { Metadata } from "../../utils/metadata"; import { Metadata } from "../../utils/metadata";
import { getLocale, getLocalizations } from "../../utils/locales"; import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc"; import { getFilename } from "../../utils/misc";
import { Player, SearchResult, useMasterPlayer, useQueue } from "discord-player"; import { Player, QueryType, SearchResult, useMasterPlayer, useQueue } from "discord-player";
export default { export default {
scope: () => [], scope: () => [],
@ -118,6 +118,7 @@ export default {
const result = await player const result = await player
.search(query, { .search(query, {
requestedBy: interaction.user, requestedBy: interaction.user,
searchEngine: QueryType.YOUTUBE_SEARCH,
}) })
.then((x) => x); .then((x) => x);
@ -170,9 +171,14 @@ export default {
}, 2900); }, 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 */ * 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) => { .then((res) => {
clearTimeout(timeoutId); clearTimeout(timeoutId);
return (res as SearchResult).tracks; return (res as SearchResult).tracks;