试图发出ping命令,想要在嵌入状态下编辑“ Pinging ...”命令,但不知道如何获取“ Pinging ...”命令的信息
这是我的代码:
}else if(command === "ping"){
const msg = message.channel.send('Pinging...');//.then(fetch);
const msginfo = Discord.TextChannel.message.fetch(msg);
console.log(msginfo);
const embedPing = new Discord.MessageEmbed()
.setColor(0xC1CCDE)
.setTitle('Pong!')
.setDescription(`Bot Latency is **${Math.floor(msg.createdTimestamp - message.createdTimestamp)} ms** \nAPI Latency is **${Math.round(client.ws.ping)} ms**`);
setTimeout(() => message.channel.send(embedPing), 100);
答案 0 :(得分:2)
您只需将await
添加到message.channel.send
,然后使用等待时间信息编辑消息
const msg = await message.channel.send('Pinging...');
msg.edit(`Bot Latency is **${Math.floor(msg.createdTimestamp - message.createdTimestamp)} ms** \nAPI Latency is **${Math.round(client.ws.ping)} ms**`);