如何通过机器人的ID和给出的消息使机器人与人冲突

时间:2020-04-03 17:06:10

标签: javascript discord.js

我想知道如何将其卡在随机用户DMS上使用cv?bot的僵尸程序中[购买],然后该僵尸程序从僵尸程序中获取消息,并从用户dm中发送用户消息至另一个用户将其ID与用户的ID以及bot DMS发送的消息一起使用

1 个答案:

答案 0 :(得分:0)

假设这是您想要的结果(即使用我的ID,以便他发回邮件给我):

bot gif

client.on('message', message => {

  if (message.content.toLocaleLowerCase().startsWith("cv?buy") == true) {
    let msg = message.content;
    let arr = msg.split(" "); // make it into an array
    let user = client.users.cache.get(arr[1]); // array's position 1 is the ID
    let code = ""; // this will be the message
    for (let i = 2; i < arr.length; i++) { // go from position 2 to the end of array
      code += `${arr[i]} `; // add those words to the message
    }
    user.send(code); // send the message to the user whose ID you typed
  }

});

当然语法是:cv?buy [user.id] [message]