Discord.JS Message in a specific Channel

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.


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}`))