[英]Resolving a promise
我正在嘗試查找頻道中的消息是否仍然存在,但是,我不確定如何解決 promise,查看其他答案和文檔我可以看到它可能是通過 function,但我不完全確定關於如何做到這一點。 我將不勝感激,因為這是我的 Discord 機器人上新功能的最后一步。
const embedId = embedChannel.messages.fetch(foundtEmbed.ticketembedchan);
console.log(embedId)
當前輸出Promise { <pending> }
您應該使用async/await
或使用then
:
try {
const embedId = await embedChannel.messages.fetch(foundtEmbed.ticketembedchan);
console.log(embedId)
}catch(err) {
console.log(err)
}
不要忘記將async
添加到您的 function。 或者:
embedChannel.messages.fetch(foundtEmbed.ticketembedchan)
.then(res => console.log(res))
.catch(err => console.log(err))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.