basic Discord bot issues node.js
Mathman05 (1)

I have a discord server that I have my bot on and I have a channel I would like it to post to, I can figure out how to get the channel. Does anyone know how I would do this?

You are viewing a single comment. View All
SixBeeps (5334)

First get the channel ID

Then fetch the ID in code and send a message to it

client.channels.fetch('CHANNEL ID HERE')
  .then(channel => channel.send("This is a message!"))
  .catch(console.error);
Coder100 (18903)

but that's only if you know the id, and sometimes you don't know the id? @SixBeeps

SixBeeps (5334)

@Coder100 No, you'll always have access to the ID as long as the channel is visible. Either way, using the channel name is more intuitive, so your answer is better.

Mathman05 (1)

@SixBeeps thanks I can't test it right now but that should work! I know the ID.