artvandelay
artvandelay

Reputation: 99

How do I "Link" a channel like a mention in my Discord Bot message?

I'd like our Discord Bot to mention a specific channel, and let it be clickable. I understand mentioning a user you use the user ID. I do have the channel Id, just unsure how to implement it.

Upvotes: 6

Views: 53416

Answers (3)

user14488588
user14488588

Reputation:

Channels on Discord have this special kinda syntax here:

<#channel id>

As commented by Elitezen here, running toString() on a Channel can do that mention for you. Then, just send that string yourself. It's much simpler than manually doing it.

Like this if you're answering a message:

message.channel.send(message.channel.toString());

Also, like answered by others in this question, you can do that yourself if you feel like it.

If you have a Channel object already, you can do something like this (imagine your channel is named myChannel - it doesn't have to be named that, though):

message.channel.send(`<#${message.channel.id}>`);

Upvotes: 1

Gilles Heinesch
Gilles Heinesch

Reputation: 2990

You just have to do the following:

message.channel.send('Please take a look at this Discord Server channel <#CHANNELID>')

or if you get the channel id from the bot

const channel = message.guild.channels.find(channel => channel.name === 'Name of the channel');
message.channel.send(`Please take a look at this Discord Server channel <#${channel.id}>`)

Then the channel is clickable like in this screenshot:

Overview how a clickable channel looks like

Upvotes: 13

DNLST
DNLST

Reputation: 153

It is simple :^)

<#channel.id>

Upvotes: 6

Related Questions