0
votes

I'm trying to make an embed link to a clickable audio channel in Discord for example this way: Click to Join But in the MessageEmbed This Code:

if (message.member.voice.channelID == null) return message.channel.send("null");

message.delete();

let link =
    "https://discord.com/channels/" +
    message.guild.id +
    "/" +
    message.member.voice.channelID;

message.channel.send(
    new Discord.MessageEmbed().setDescription(
        "[Click to Join](" + `${link}` + ")"
    )
);

Probably my fault is on the link, I could not find anything on the internet.

1

1 Answers

1
votes

Discord at the moment does not let you join a voice channel through it's channel's link, but rather through an invite, that can be created through the Channel#createInvite() method.

We can create an invite to our voice channel, and send the invite through an embed to join through.

Final Code

if (message.member.voice.channelID == null) return message.channel.send('null')
     
message.delete()
let invite = await message.member.voice.channel.createInvite()
let link = `https://discord.gg/${invite.code}`
const embed = new Discord.MessageEmbed().setDescription(`[This](${link}) is a test`);
    
message.channel.send(embed);