mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
23 lines
959 B
JavaScript
23 lines
959 B
JavaScript
async function execute(interaction) {
|
|
const channel = interaction.member.voice.channel;
|
|
if (!channel) return interaction.reply('You are not connected to a voice channel!'); // make sure we have a voice channel
|
|
const query = interaction.options.getString('query', true); // we need input/query to play
|
|
|
|
// let's defer the interaction as things can take time to process
|
|
await interaction.deferReply();
|
|
|
|
try {
|
|
const { track } = await player.play(channel, query, {
|
|
nodeOptions: {
|
|
// nodeOptions are the options for guild node (aka your queue in simple word)
|
|
metadata: interaction // we can access this metadata object using queue.metadata later on
|
|
}
|
|
});
|
|
|
|
return interaction.followUp(`**${track.title}** enqueued!`);
|
|
} catch (e) {
|
|
// let's return error if something failed
|
|
return interaction.followUp(`Something went wrong: ${e}`);
|
|
}
|
|
}
|