feat: Music support #62
1 changed files with 20 additions and 6 deletions
|
@ -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")}.`,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue