【问题标题】:Send a direct message to user instead of channel向用户发送直接消息而不是频道
【发布时间】:2021-04-07 04:49:37
【问题描述】:

所以我一直试图弄清楚如何将此嵌入发送到用户 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!')
      


  }
}

【问题讨论】:

  • message.reply(embed); 怎么样?
  • 那不做任何事情,仍然将嵌入发送到频道中。我需要它来 dm 用户
  • 这能回答你的问题吗? Sending private messages to user

标签: javascript node.js discord discord.js


【解决方案1】:

Shoejep 回答了这个问题

message.author.send(embed);

【讨论】:

    【解决方案2】:

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

    superCoolUserOmg.send(superCoolEmbedOmg)
    

    【讨论】:

      猜你喜欢
      • 2017-05-16
      • 1970-01-01
      • 2018-12-16
      • 2020-09-05
      • 2021-01-10
      • 2021-03-24
      • 2021-03-22
      • 2020-04-07
      • 1970-01-01
      相关资源
      最近更新 更多