As you know recently discord.js has moved to v13. I try to send a message in a specific channel but it gives me an error. Here's my code:
let channel = client.channels.cache.get(CHANNEL_ID)
channel.send(`${MSG}`)
This is my error:
TypeError: Cannot read property 'send' of undefined
Please help me. I've tried finding similar topics here and the only solution I found was in typescript but I want it in javascript.
Using client.guilds.cache.get("ID").channels.cache.get("ID").send() should help!
You could also use:
let channel = GUILD.channels.cache.get(CHANNEL_ID);
channel.send(MSG);
discord.js v13 needs you to specify which events you want your bot to receive. To achieve this you need to select, so called "Gateway Intents".
Here is a guide on Gateway Intents and how you configure them.
Here is a list of all Intents and what events they allow your bot to receive.