本文介紹了獲取消息(按 ID)并進行編輯的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在嘗試以不同的功能編輯機器人發送的消息.
I'm trying to edit a message the bot sent, in a different function.
const msg = message.channel.fetchMessage(msgId);
msg.edit(embed);
沒有工作,因為 msg.edit 不是一個函數.
Didn't work because msg.edit is not a function.
message.channel.messages.fetch({around: "352292052538753025", limit: 1})
.then(messages => {
messages.first().edit("test");
});
沒有工作,因為 .fetch 不是函數.
Didn't work because .fetch is not a function.
function update(msgId, time, channelid, prize, winnersInt, message) {
setTimeout(function(){
let gtime = time/3600000 + " hours remaining!";
if(time < 3600000) {
gtime = time/60000 + " minuets remaining!";
}
console.log(gtime + "p: " + prize);
let embed = new Discord.RichEmbed()
.setColor("#7289da")
.setTitle("Giveaway!")
.addField('Prize: ', prize)
.addField('Amount of winners: ', winnersInt)
.addField('Time: ', gtime)
const msg = message.channel.fetchMessage(msgId);
msg.edit(embed);
time - 60000;
if(time > 0) {
update(msgId, time, channel, prize, winnersInt, message);
}
}, 60000);
}
我希望消息被編輯.
推薦答案
搞定了.
用過這個:
message.channel.fetchMessages({around: msgId, limit: 1})
.then(msg => {
const fetchedMsg = msg.first();
fetchedMsg.edit(embed);
});
這篇關于獲取消息(按 ID)并進行編輯的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!