Fetch a message (by ID) and edit it(获取消息(按 ID)并进行编辑)
本文介绍了获取消息(按 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)并进行编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
织梦狗教程
本文标题为:获取消息(按 ID)并进行编辑


基础教程推荐
猜你喜欢
- Bokeh Div文本对齐 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01