A
A
Anton18632021-03-16 13:28:06
Node.js
Anton1863, 2021-03-16 13:28:06

How to send a message to a channel by id on the "ready" event?

The fact is that the Internet offers such a solution:

const Discord = require('discord.js');
const bot = new Discord.Client();
bot.login(TOKEN);
bot.on('ready', () => {
bot.channels.get(CHANNEL_ID).send(MESSAGE);
});

But it doesn't work for me, I suspect that the API has changed, so the object that returns after going to the "channels" property does not have the "get" method, the other methods are of little use.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-03-16
@Anton1863

bot.guilds.cache.get("id_сервера").channels.cache.get("сообщение")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question