TypeError: Cannot read property 'send' of undefined(77:15)

There is no where near enough information here to determine what is happening. You’re posting multiple messages however and they all seem to be related to one fundamental problem. You are trying to access properties and functions of the client before logging in.

how to fix it?

I’m guessing after having seen a screen capture you supplied in another message. It looked like you were trying to access data from the client and then a few lines further down you were connecting to Discord.

You need to create the connection or the data will not be there. My recommendation regardless of what the specific problem is, is that you get a “Hello World” example working. Your bot runs and it handles a single command message. Make it do more after that.

Oh… a quick comment. If I (or anyone) had posted a screen capture of 2.5 lines of code would you have jumped in with a possible solution? You do see how there is no information there at all right? We even have to deduce that you are writing a Discord Bot.

sorry keep other screenshots

I can see that your code isn’t used before the connection now. I think you would benefit from adding a little logging to let you know that the bot connected, there are events for that.

Also I assume that you are running it from VC Code and not from Glitch right? It looks like it didn’t find the channel you asked for, would you agree? If so then what makes you think the Id is correct? If you checked that then log what is returned and I think you will see not a channel.

I believe you will have to fetch the channel rather than rely on the cache.

const channel = await client.channels.fetch(config.generalTextChannelId);

I keep the channelId in a config file, you can hardcode it if you like. I call a function to build the return message you can do it inline if you like.

And if I do not have a config file but have an .env file, the function will be called process.env. …?

You can read the process.env.TOKEN (for instance) using dotenv. It will be in the .env file on your local machine but in the env editor in Glitch. You shouldn’t upload your .env file to GitHub or Glitch.

That said consider adding a config file it is handy for the configuration items you will probably have. Logging levels, max this, min that, colors, external URL’s, etc. Then you just get your config module to read the .env data and it is there along with the other config items.