本文介紹了DiscordJS Bot - 如何在頻道中的另一條消息之前立即獲取消息?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我創建了一個使用 DiscordJS 來監控消息的機器人.例如:
I've created a bot using DiscordJS to monitor messages. For example:
client.on("message", function(message) {
// Do stuff
});
我想知道是否有一種可能的方法來獲取在頻道中當前消息對象之前立即發送的消息.
I would like to know if there is a possible way to fetch the message that was immediately sent before the current message object in the channel.
推薦答案
我想我通過這樣做找到了一個令人滿意的方法:
I think I've found a satisfactory method by doing something like this:
message.channel.fetchMessages({limit: 2})
.then(messageMappings => {
let messages = Array.from(messageMappings.values());
let previousMessage = messages[1];
// do something with previous message
})
.catch(error => Logger.log("error", "Error fetching messages in channel"))
這篇關于DiscordJS Bot - 如何在頻道中的另一條消息之前立即獲取消息?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!