Cahan uuu
Cahan uuu

Reputation: 61

How to create voice channel link

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.

Upvotes: 0

Views: 1136

Answers (1)

Itamar S
Itamar S

Reputation: 1565

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);

Upvotes: 1

Related Questions