本文介紹了獲取我的機器人發(fā)送的消息的消息 ID的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我需要獲取我的不和諧機器人發(fā)送的消息的消息 ID(它發(fā)送豐富的嵌入)
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 解決您剛剛發(fā)送的消息.
要處理該消息,您可以使用 await
將其存儲在變量中或使用 Promise.then()
并將其余代碼作為函數(shù)傳遞.
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);
});
這篇關于獲取我的機器人發(fā)送的消息的消息 ID的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!