Send Private Message Discord Js With Userid

🛑 👉🏻👉🏻👉🏻 INFORMATION AVAILABLE CLICK HERE👈🏻👈🏻👈🏻
Sign up or log in to view your list.
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.
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.
adapap
adapap 515●11 gold badge●77 silver badges●1919 bronze badges
Federico Grandi
6,220●44 gold badges●2424 silver badges●4343 bronze badges
I do not work with discord.js yet. Can you create an User-Object? If so, you can use UserObject.sendMessage("string"); – R. Pülsinger Jan 19 '17 at 15:15
The bot is a client, here is the doc page: discord.js.org/#/docs/main/stable/class/Client. Your code won't work because sendMessage isn't a method of the client. I am going to see if I can create a user object. – adapap Jan 19 '17 at 15:41
Have you tried message.author.sendMessage("XXX")? I use this in the version 10.0.1 of the lib. – JulCh Jan 19 '17 at 16:17
@JulCh I would choose you as the answer. Thanks a ton, I got it working! One more thing if you have the time, how do I check if the (user, not bot) message was sent in a direct message? – adapap Jan 19 '17 at 20:16
@adapap You can check if the message.channel object is an instance of DMChannel (Direct message channel), or a TextChannel for a classic channel :) – JulCh Jan 19 '17 at 23:12
In order for a bot to send a message, you need .send() , the client is where the bot will send a message to(A channel, everywhere in the server, or a PM). Since you want the bot to PM a certain user, you can use message.author as your client. (you can replace author as mentioned user in a message or something, etc)
Hence, the answer is: message.author.send("Your message here.")
I recommend looking up the Discord.js documentation about a certain object's properties whenever you get stuck, you might find a particular function that may serve as your solution.
Kaynn
Kaynn 3,395●22 gold badges●1717 silver badges●2323 bronze badges
SirDerpington
10.4k●44 gold badges●4646 silver badges●5353 bronze badges
Remember that the discord.js documentation (discord.js.org/#/docs/main/stable/general/welcome) is written as a javadoc and may not always be effective for usage examples or translating intention into code. It is unwise to suggest someone study the entire library for a specific implementation when such sites as StackOverflow exist for that. It is best to point them to documentation relative to their question instead (discord.js.org/#/docs/main/stable/search?q=sendmessage). – Abandoned Cart Apr 2 '17 at 16:09
.sendMessage('content') is now deprecated - instead, use .send('content') – Blundering Philosopher Mar 1 '18 at 22:16
The above answers work fine too, but I've found you can usually just use message.author.send("blah blah") instead of message.author.sendMessage("blah blah").
-EDIT- : This is because the sendMessage command is outdated as of v12 in Discord Js
.send tends to work better for me in general than .sendMessage, which sometimes runs into problems. Hope that helps a teeny bit!
SuperNunb
SuperNunb 121●22 silver badges●1111 bronze badges
Dynamic Games
73●11 silver badge●44 bronze badges
Indeed, sendMessage() is deprecated. – Pritt Balagopal Sep 6 '18 at 8:03
To send a message to a user you first need to obtain a User instance.
Once you got a user instance you can send the message with .send
tomer zeitune
tomer zeitune 767●77 silver badges●1313 bronze badges
.fetchUser() is no longer a valid function... – ATR Jan 24 at 18:01
@ATR It's client.users.fetch now. – qz- Jun 30 at 17:07
where '487904509670337509' is an id number.
Edmazing
Edmazing 74●55 bronze badges
If your looking to type up the message and then your bot will send it to the user, here is the code. It also has a role restriction on it :)
case 'dm':
mentiondm = message.mentions.users.first();
message.channel.bulkDelete(1);
if (!message.member.roles.cache.some(role => role.name === "Owner")) return message.channel.send('Beep Boing: This command is way too powerful for you to use!');
if (mentiondm == null) return message.reply('Beep Boing: No user to send message to!');
mentionMessage = message.content.slice(3);
mentiondm.send(mentionMessage);
console.log('Message Sent!')
break;
Dynamic Games
Dynamic Games 73●11 silver badge●44 bronze badges
Lioness100
7,395●55 gold badges●1111 silver badges●4545 bronze badges
If you want to send the message to a predetermined person, such as yourself, you can set it so that the channel it would be messaging to would be their (your) own userID. So for instance, if you're using the discord bot tutorials from Digital Trends, where it says "to: ", you would continue with their (or your) userID. For instance, with how that specific code is set up, you could do "to: userID", and it would message that person. Or, if you want the bot to message you any time someone uses a specific command, you could do "to: '12345678890'", the numbers being a filler for the actual userID. Hope this helps!
This is pretty simple here is an example
Lioness100
7,395●55 gold badges●1111 silver badges●4545 bronze badges
Make the code say if (msg.content === ('trigger') msg.author.send('text')}
DisBotDev1
DisBotDev1 1●11 bronze badge
syntax error.. should be if (msg.content === 'trigger') msg.author.send('text'). one ( and } too much – Fipsi Jul 11 '19 at 9:43
Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.
2021 Stack Exchange, Inc. user contributions under cc by-sa
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Accept all cookies Customize settings
Hmm, looks like we don’t have any results for this search term. Try searching for a related term below.
Little Teen Pussy Forum
Photos Of Big Beautiful Naked Women Pussy
Xxx Video Smotret Besplatno
Beautiful Sexy Lesbian Girls
Shemale Sexy Feet
Sending private messages to user – JavaScript
Use Discord API to send a private message given a user ID ...
discord.js send private message to @user Code Example
Discord.JS - How do I make a Discord bot send somebody a ...
How do I Send A Direct Message With a Users' ID? · Issue ...
How to send a private message on discord - Kodlogs
How to send a DM to a user by their user id? : Discord_Bots
Discordjs - Cannot send messages to this user
Send Private Message Discord Js With Userid







































































