本文介紹了獲取我的機器人發送的消息的消息 ID的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我需要獲取我的不和諧機器人發送的消息的消息 ID(它發送豐富的嵌入)
I need to get the message id of the message my discord bot sends (it sends a rich embed)
謝謝
推薦答案
當你使用 TextChannel.send()
(或 Discord.js 中的任何其他類型的 .send
),它返回一個 Promise 解決您剛剛發送的消息.
要處理該消息,您可以使用 await
將其存儲在變量中或使用 Promise.then()
并將其余代碼作為函數傳遞.
When you use TextChannel.send()
(or any other kind of .send
in Discord.js), it returns a Promise that resolves with the message you just sent.
To work with that message, you can either use await
to store it in a variable or use Promise.then()
and pass the rest of your code as a function.
這是一個例子:
// 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);
});
這篇關于獲取我的機器人發送的消息的消息 ID的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!