Skip to content
Advertisement

Discord bot only replying to initator

I am starting with a new Discord bot using discord.js. I am still learning things but am curious if it is possible to send a reply to only the initiator, not the channel.

Channel.send and message.reply are both public to all.

const discord = require('discord.js');
const client = new discord.Client;
const prefix = '!';

client.once('ready', () => {
  console.log('Ready!');
});

client.on('message', message => {
  if (message.content === 'ping') {
    message.channel.send('Pong!');
  }
});

Advertisement

Answer

To dm the person who said the message do

message.author.send("hullo");

To send it to someone else,

let user = client.users.cache.get(`PUT-YOUR-ID-HERE`);
user.send("hullo");
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement