How to make my bot DM
So I am making a discord bot with discord.js and I need to find out how to make it DM a user if any way please say bellow
You can use the <user>#send method as seen in the docs
If you want to send to the author of the message, use the <user>#send method or
If you want to send to a user by id, fetch a user and send using the .send() function. Make sure they are in the cache. To fetch a user, use the <user>#fetch method.
Note: change client to what you defined client as.
const user = <client>.users.cache.fetch(id); user.send();
Yes you can! If you have their ID, it is very easy.
const user = client.users.cache.fetch("<USER ID>"); user.send("Hello, world!");
If you don't have the user id, don't worry, you can still do it by username, as long as they are in a server the bot is in too.
const user = client.users.cache.find(user => user.username == "<USER NAME>"); user.send("Hello, worlD!");
please mark as correct answer, thanks!