-1

I want to add a feature to the bot, to contact a user in private with his id in parameter.

I already tried this:

sendMessage(idUser, "mesage")

but it doesn't work.

I have this error:

"sendMessage is not defined"

krlzlx
  • 5,752
  • 14
  • 47
  • 55
  • 1
    you need to give more details what you have tried so far – ArunPratap Jun 09 '18 at 12:42
  • i have tried this : bot.sendMessage(user, "my message"); bot.message(user, "my message"); I want to know if it's possible to contact a user in private message with this id, cause i don't find anything about private message by userId – Marcel Patoulatchi Jun 09 '18 at 12:55
  • u need to add some more code how u are doing this so that we can understand what is problem – ArunPratap Jun 09 '18 at 12:58
  • const Discord = require('discord.js') const bot = new Discord.Client() bot.on('message' function(message)){ sendMessage( auserid , "HELLO WORLD") } You don't need the rest of the code. – Marcel Patoulatchi Jun 09 '18 at 13:15

2 Answers2

0

Try message.author.send("Your message here"); This takes the author of the sent message and sends a message to them.

Please note for the future, however, that sendMessage is depreciated in discord.js. Instead, just use send.

Trifex
  • 178
  • 12
0

Yeah message.author.send("MESSAGE") should work

Also a little handy tip \n makes a new line if your making lines of text :D

SovietSeal
  • 123
  • 1
  • 2
  • 14