Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在discord dms中的机器人通过其ID和给定的消息将其定位到某个人的位置_Javascript_Discord.js - Fatal编程技术网

Javascript 如何在discord dms中的机器人通过其ID和给定的消息将其定位到某个人的位置

Javascript 如何在discord dms中的机器人通过其ID和给定的消息将其定位到某个人的位置,javascript,discord.js,Javascript,Discord.js,我想知道你怎么能做到这一点,我被困在其中,一个随机用户使用cv?buy[代码]对机器人进行DMS,然后机器人从机器人和用户dm接收消息,并使用其ID将用户消息发送给另一个用户,用户从其和机器人DMS发送消息 假设这是您想要的结果(我正在使用我的ID,所以他会给我回信息): client.on('message',message=>{ if(message.content.tolocalLowercase().startsWith(“cv?buy”)==true){ 让msg=message.c

我想知道你怎么能做到这一点,我被困在其中,一个随机用户使用cv?buy[代码]对机器人进行DMS,然后机器人从机器人和用户dm接收消息,并使用其ID将用户消息发送给另一个用户,用户从其和机器人DMS发送消息


假设这是您想要的结果(我正在使用我的ID,所以他会给我回信息):

client.on('message',message=>{
if(message.content.tolocalLowercase().startsWith(“cv?buy”)==true){
让msg=message.content;
让arr=msg.split(“”;//将其放入数组中
让user=client.users.cache.get(arr[1]);//数组的位置1是ID
让code=”“;//这将是消息
对于(设i=2;i

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

您应该显示一个示例/代码片段,您在其中尝试了这项工作。我有点搞不清楚您实际上在做什么。你只是想用一个给定的ID对一个用户进行DM吗?如果我错了,请纠正我,并确认我是否正确。您想要:User1到DM bot1。那么bot1将DM bot2和user2结合起来吗?
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
  }

});