I'm using the discord.js library and node.js to create a Discord bot that facilitates poker. It is functional except the hands are shown to everyone, and I need to loop through the players and send them a DM with their hand.
bot.on("message", message => {
message.channel.sendMessage("string");
});
This is the code that sends a message to the channel when any user sends a message. I need the bot to reply in a private channel; I've seen dmChannel
, but I do not understand how to use it. I have the username of the member that I want to send a message to.
An example would be appreciated.
Edit:
After looking around for a user object, I found that I can get all of the users using the .users
property of the client (bot). I will try using the user.sendMessage("string")
method soon.
UserObject.sendMessage("string");
– R. Pülsingermessage.author.sendMessage("XXX")
? I use this in the version 10.0.1 of the lib. – JulChmessage.channel
object is an instance of DMChannel (Direct message channel), or a TextChannel for a classic channel :) – JulCh