Reputation: 83
I'm trying to make my bot join the voice channel I'm currently using, but I can't seem to find how to get the message author's current voice channel.
So far I've seen suggestions to use message.member.voiceChannel
but it doesn't work, message.member
has no voiceChannel
attribute.
I'm looking for something that works like this:
async execute(interaction) {
const connection = joinVoiceChannel({
channelId: interaction.member.voiceChannel,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
}
Upvotes: 2
Views: 3480
Reputation: 23189
It's message.member.voice.channel
, not voiceChannel
.
Even then, you don't provide an ID at channelId: interaction.member.voice.channel
. The channel ID should be interaction.member.voice.channel.id
:
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
Upvotes: 3
Reputation: 197
Use interaction.member.voice.channel
, interaction.guildId
, and interaction.guild.voiceAdapterCreator
Upvotes: -1