向用户而不是频道发送直接消息

时间:2020-12-30 17:29:03

标签: javascript node.js discord discord.js

所以我一直在试图弄清楚如何将此嵌入发送到用户 dms 而不是频道,但我发现的所有帖子都与我的问题无关或已过时,根本不起作用。

  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!')
      


  }
}

2 个答案:

答案 0 :(得分:1)

您可以使用 User#send() 方法向用户发送 DM 例子:

superCoolUserOmg.send(superCoolEmbedOmg)

答案 1 :(得分:0)

Shoejep 回答了这个问题

message.author.send(embed);