Discord.js Bot mentioning Voice Channels

Viewed 430

I have a specific event (voiceStateUpdate) that has to mention sometimes a Voice Channel:

            channel.send(`The Channel is:`+"``"+`<#${newMember.channelID}>`+"``");

As one can see, I want that the channel is being mentioned with those `` around them, so the channel in Discord is in this black box. But my actual output looks like this:

The Channel is: <#1234134234134>

So in Discord this Black Box works, but the Channel is displayed not with its name, but with the ID

2 Answers

To get the right result, you simply imitate Discord's conversion of the format <#CHANNELID>.

channel.send(`The Channel is:`+"`"+`${newMember.channel.name}`+"`");

This will get the exact same result, as if one would post as a user the message with Discord's conversion form

Try it this way:

channel.send('`' + `The Channel is: <#${newMember.channelId}>` + '`');

For a single line code block you only need to wrap it in grave accents once.

Edit:

grafpatron's answer is the correct one

Related