Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.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 获取我的bot发送的消息的消息ID_Javascript_Node.js_Discord.js - Fatal编程技术网

Javascript 获取我的bot发送的消息的消息ID

Javascript 获取我的bot发送的消息的消息ID,javascript,node.js,discord.js,Javascript,Node.js,Discord.js,我需要获取discord bot发送的消息的消息id(它发送一个丰富的嵌入) 谢谢当您使用(或Discord.js中的任何其他类型的.send)时,它将返回一个与您刚才发送的消息解析的值。 要处理该消息,可以使用wait将其存储在变量中,也可以使用并将其余代码作为函数传递 下面是一个例子: // with async/await: async function replyAndLog() { let sent = await message.reply("Your stuff..."); /

我需要获取discord bot发送的消息的消息id(它发送一个丰富的嵌入)

谢谢

当您使用(或Discord.js中的任何其他类型的
.send
)时,它将返回一个与您刚才发送的消息解析的值。
要处理该消息,可以使用
wait
将其存储在变量中,也可以使用并将其余代码作为函数传递

下面是一个例子:

// with async/await:
async function replyAndLog() {
  let sent = await message.reply("Your stuff..."); // this returns the message you just sent
  let id = sent.id; // you can get its ID with <Message>.id, as usually
  console.log(id);
}

// with <Promise>.then():
message.reply("Your stuff").then(sent => { // 'sent' is that message you just sent
  let id = sent.id;
  console.log(id);
});
//使用异步/等待:
异步函数replyAndLog(){
let sent=wait message.reply(“您的东西…”);//返回您刚才发送的消息
let id=sent.id;//通常可以使用.id获取其id
console.log(id);
}
//使用。然后()
message.reply(“你的东西”)。那么(sent=>{/'sent'就是你刚才发送的消息吗
让id=sent.id;
console.log(id);
});

你能发布你到目前为止已经尝试过的内容吗?Message.id@gratienasimbah怎么样?我们还没有真正尝试过任何东西,因为没有任何帖子显示要做什么do@doniyor2109我相信它会获取用户发送来激活命令的消息的消息ID,很高兴听到:)