discord.js

Discord.js Voice Channel with Slash Commands


I want to create a Music Bot with the new Discord Slash Commands, but I don't know how to get the voice channel which the user is in.

With a normal Message-Command it's message.member.voice.channel.


Solution

  • Because interaction.member doesn't contain any voice information, i defined the voice channel as follows:

    const guild = client.guilds.cache.get(interaction.guild_id)
    const member = guild.members.cache.get(interaction.member.user.id);
    const voiceChannel = member.voice.channel;