简体   繁体   中英

Send a direct message to user instead of channel

So i've been trying to figure out how to send this embed to a users dms instead of a channel, but all of the posts i've found are irrelevant to my question or outdated and don't work at all.

  module.exports = {
  name: 'help',
  description: 'this is a help command!',
  execute(message, args){

      const embed = new Discord.MessageEmbed()
      .setTitle('List of Commands')
            .setDescription('This embed lists all of my commands.')
            .setColor('#ed2626')
            .addFields({
              name: '+help',
              value: 'Shows a list of commands',
              inline: true
            }, {
              name: '+ping',
              value: 'Show your insolence to krennic!',
              inline: true
            }, {
              name: 'Test Number 3',
              value: 'This is a example value'
            }, {
              name: 'Test Number 4',
              value: 'This is a example value'
            })
            .setTimestamp();

      // This right here is what i'm trying to figure out
      // Instead of sending in the channel how would i dm the person that calls the command?
      message.channel.send(embed);
      console.log('Help command was ran!')
      


  }
}

You can send a DM to a user using the method User#send() example:

superCoolUserOmg.send(superCoolEmbedOmg)

Shoejep answered this

message.author.send(embed);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM