Untitled
unknown
plain_text
2 years ago
2.2 kB
9
Indexable
const { ApplicationCommandOptionType, EmbedBuilder } = require("discord.js");
const { formatDuration } = require("../../functions/timeFormat.js");
module.exports = {
name: "play",
description: "Play your favorite song/s.",
category: "Music",
options: [
{
name: "query",
description: "Provide song name/url.",
type: ApplicationCommandOptionType.String,
required: true,
},
],
permissions: {
bot: ["Speak", "Connect"],
user: [],
channel: ["Speak", "Connect"],
},
settings: {
inVoice: true,
sameVoie: false,
player: false,
current: false,
owner: false,
},
run: async (client, interaction, player) => {
const song = interaction.options.getString("query");
const embed = new EmbedBuilder().setColor(client.embedColor);
if (player && interaction.member.voice.channel.id !== interaction.guild.members.me.voice.channel.id) {
embed.setDescription(`\`❌\` | You must be on the same voice channel as mine to use this command.`);
return interaction.reply({ embeds: [embed] });
}
const res = await client.manager.search(song, { requester: interaction.user });
if (!res.tracks.length) {
embed.setDescription(`\`❌\` | No song found or song failed to load!`);
return interaction.reply({ embeds: [embed] });
}
if (!player) {
player = await client.manager.create({
guildId: interaction.guild.id,
voiceId: interaction.member.voice.channel.id,
textId: interaction.channel.id,
deaf: true,
});
}
if (res.type === "PLAYLIST") {
for (const track of res.tracks) {
player.queue.add(track);
}
embed.setDescription(`\`☑️\` | **[${res.playlistName}](${song})** • \`${tracks.length}\` tracks • ${interaction.user}`);
} else {
const track = res.tracks[0];
player.queue.add(track);
embed.setDescription(
`\`☑️\` | **[${track.title ? track.title : "Unknown"}](${track.uri})** • \`${
track.isStream ? "LIVE" : formatDuration(track.duration)
}\` • ${interaction.user}`,
);
}
if (!player.playing || !player.paused) player.play();
return interaction.reply({ embeds: [embed] });
},
};Editor is loading...
Leave a Comment