support for playlist

This commit is contained in:
Mylloon 2023-02-05 23:53:59 +01:00
parent 04ab72ab66
commit 593da97e33
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -5,7 +5,7 @@ import {
GuildResolvable,
VoiceBasedChannel,
} from "discord.js";
import { Metadata } from "../../modules/metadata";
import { Metadata } from "../../utils/metadata";
import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
@ -84,20 +84,34 @@ export default {
}
await interaction.deferReply();
const track = await client.player
const result = await client.player
.search(query, {
requestedBy: interaction.user,
})
.then((x) => x.tracks[0]);
.then((x) => x);
if (!track) {
if (!result.tracks[0]) {
return await interaction.followUp({ content: `❌ | \`${query}\` ${loc.get("c_play4")}.` });
}
queue.play(track);
let title;
if (result.playlist) {
queue.addTracks(result.playlist.tracks);
title = result.playlist.title;
} else {
// TODO: Ask user which result to choose
const track = result.tracks[0];
queue.addTrack(track);
title = track.title;
}
if (!queue.playing) {
queue.play();
}
return await interaction.followUp({
content: `⏱️ | \`${track.title}\` ${loc.get("c_play5")}.`,
content: `⏱️ | \`${title}\` ${loc.get("c_play5")}.`,
});
},
};