-1

So i'm new to the whole Discord.JS thing and i am trying to figure out how to get the bot to write a message to the General Chat when a new person joins.

I have seen a lot of people doing it like this:

const channel = client.channels.cache.find(channel => channel.name === channelName)
channel.send(message)

But this isnt working for me. Whenever i am trying to send a message with the channel.send(message) it gives me a error message.

I have also tried the version where you do it with the client.channels.cache.get(<Channel-ID>)

But this also didnt work for me.

  • 1
    Share the error message you receive. – ThatsLiamS Jan 12 '22 at 21:03
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 21 '22 at 05:11

1 Answers1

1

Use this code similar to the post: how to send a message to specific channel Discord.js

<client>.channels.fetch('<id>').then(channel => channel.send('<content>'))

Example

client.channels.fetch('922880975074127872')
.then(channel => channel.send(`Welcome, ${user}`))
Bailey
  • 33
  • 7