support for playlist
This commit is contained in:
parent
04ab72ab66
commit
593da97e33
1 changed files with 20 additions and 6 deletions
|
@ -5,7 +5,7 @@ import {
|
||||||
GuildResolvable,
|
GuildResolvable,
|
||||||
VoiceBasedChannel,
|
VoiceBasedChannel,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { Metadata } from "../../modules/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";
|
||||||
|
|
||||||
|
@ -84,20 +84,34 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
const track = await client.player
|
const result = await client.player
|
||||||
.search(query, {
|
.search(query, {
|
||||||
requestedBy: interaction.user,
|
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")}.` });
|
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({
|
return await interaction.followUp({
|
||||||
content: `⏱️ | \`${track.title}\` ${loc.get("c_play5")}.`,
|
content: `⏱️ | \`${title}\` ${loc.get("c_play5")}.`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue