How do I make my bot send a message to the user mentioned in the DM and a certain channel?
If you are using discord.js, try this:
const user = [CLIENT].users.cache.get('[USERID]');
user.send('[MESSAGE]');
i mention a user in the cmd. would that pop up in the message?
Mentioning a user in the terminal would not popup a message in a DM.
i don’t get the code part. can you restate that more clear please.
Ok so let me break this code down.
const user = client.users.cache.get('[USERID')
This will get the user ID of the person you want to DM and
user.send('[MESSAGE]')
will send the message to that person.
no. i wan’t a message send to the user i mentioned in the command.
First get the person you mention using message.mentions.users.first()
. Then send the message to the user returned.
Example:
let user = message.mentions.users.first();
user.send('whatever your message is');
can someone tell me how to do this in the glitch discord bot template?
First, welcome to the glitch community! Second, add a command. Third, use this code:
let user = message.mentions.users.first(); user.send('whatever your message is');
If you need help. DM me on discord. !techdude1610 find me in the Discord Developers server