Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a bot to mention a channel?

I am making a welcome message but I can’t seem to make it say the rule channel. I want the bot to say #rules and make it so you can click it to go to the rules channel. I know you can do this with a normal user, but I want to do it with my bot. Every time I try, it can’t be clicked like a normal player. I’ve tried doing #rules, <#channelID>, and other stuff. None of them are clickable.

like image 929
Pruina Tempestatis Avatar asked Mar 18 '18 23:03

Pruina Tempestatis


People also ask

How do I get mee6 to mention a channel?

FIrst, go to your server and type \#your-channel (do not forget the \) then send ur message...

How do I give a bot access to a channel?

Click "+" next to "Roles/Members." A list of server users will appear. Click the name of the bot. You'll find it under "Members." Assign permissions to the bot.

How do you code a bot to mention someone?

Here you want to mention someone. Both type has a toString() method which return a string mentionning the user. For example, if you have an instance of someone in the variable oneUser , and you do channel. send('Hello ' + oneUser) , the output will be Hello @TheUser .


1 Answers

You need to send a GuildChannel for the channel name to be clickable.
You can achieve this by finding the channel in guild.channels.cache
This returns a Collection, which you can filter.
If you have an ID (easier):

var message = "Make sure to check the rules at " + 
  message.guild.channels.cache.get('channelID').toString();

If you want find the channel by ID (might break if you have multiple channels with the same name):

var message = "Make sure to check the rules at " + 
  message.guild.channels.find(channel => channel.name === "rules").toString();

EDIT:

Much easier way: in Discord mention the channel and put a \ (backslash) before the channel name \#rules. You'll get something like <#channelID>.
Use that like this: var message = "Make sure to check the rules at <#channelID>";

like image 58
André Avatar answered Sep 21 '22 01:09

André