Search code examples
discorddiscord.js

In discord.js, Can I send DirectMessage to user With DiscordBot?


I want to send private messages to a User with a Discord Bot.

The user is not in the same server as the bot.

If I can use author.sendMessage, how can I initialize(find) author variable?

Can I find the user with User id?

Thank you for reading.


Solution

  • And The user is not in the same server with bot.

    And

    I make a mistake, I want to send Privatemessage to User who isn't in same server with bot I added.. [source]

    That is not possible to do.
    Bots need to have at least 1 common server with a user to be able to send a direct message.
    If the user is on the same server as the bot, only then you can send a DM, using any of the other methods on this post.
    client.users.get("someID").send("someMessage");