Reputation: 546
I made a music bot, but I'm looking to turn this into interactions, but I'm having a problem calling the play function.
With "message" it works, but with "interaction" it doesn't. I tried to pass on some information, I searched but I couldn't.
I even found a different way, but it didn't work.
The error returned is this:
DisTubeError [INVALID_TYPE]: Expected 'Discord.Message' for 'message', but got undefined (undefined)
Play.js
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play a song!')
.addStringOption(option => option.setName('song').setDescription('Enter name of the music.')),
async execute (interaction, client){
// if(!interaction.member.voice.channel) return interaction.reply("Please, join a voice channel!");
const music = interaction.options.getString('song');
if(!music) return interaction.reply("Please, provide a song!");
await client.distube.play(interaction, music);
// await client.distube.playVoiceChannel(
// interaction.member.voice.channel,
// music,
// {
// textChannel: interaction.channel,
// member: interaction.member
// }
// );
}
}
Upvotes: 0
Views: 1953
Reputation: 1498
DisTube, at the time of this question being posted, doesn't support slash commands, and it looks like the creator doesn't have any plans on supporting it officially. As a workaround, you can use the Distube#playVoiceChannel
method instead of the Distube#play
method, like so:
await client.distube.playVoiceChannel(interaction.member.voice.channel, music);
But before you do any of that, it looks like interaction
is undefined - that's probably a problem with your command handler, so look there.
Edit: Also docs for Distube#playVoiceChannel
if you're interested
Upvotes: 2