pragmatrick
pragmatrick

Reputation: 645

Discord.js Bot mentioning Voice Channels

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

Upvotes: 2

Views: 624

Answers (2)

Toasty
Toasty

Reputation: 1880

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

Upvotes: 0

pragmatrick
pragmatrick

Reputation: 645

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

Upvotes: 1

Related Questions