如何回复发送给机器人的任何DM?

Mat*_*w08 3 discord discord.js

我试图使我的机器人回复发送给它的所有DM。

所以我目前有这个:

client.on('msg', () => {
  if (msg.channel.DMChannel) {
    msg.reply("You are DMing me now!");
  }
});
Run Code Online (Sandbox Code Playgroud)

但不幸的是,它没有回复任何DM。

我尝试用替换msg.channel.DMChannelmsg.channel.type == 'dm'但这没有用。

我也试图取代msg.replymsg.author.sendmsg.channel.send,但他们都没有工作。

任何帮助,将不胜感激。

谢谢!

And*_*dré 5

官方文档我没有看到提到的事件client.on('msg')client.on('message')
顺便说一句:

client.on('message', msg => {
  if (msg.channel.type == "dm") {
    msg.author.send("You are DMing me now!");
    return;
  }
});
Run Code Online (Sandbox Code Playgroud)

刚刚尝试过,并且没有任何问题。