Send a message with Discord.js

The send code has been changed again. Both the items in the question as well as in the answers are all outdated. For version 12, below will be the right code. The details about this code are available in this link.

To send a message to specific channel

const channel = <client>.channels.cache.get('<id>');
channel.send('<content>');

To send a message to a specific user in DM

const user = <client>.users.cache.get('<id>');
user.send('<content>');

If you want to DM a user, please note that the bot and the user should have at least one server in common.

Hope this answer helps people who come here after version 12.

Leave a Comment