当尝试使用discord.js将不和谐消息编辑为RichEmbedded消息时,出现错误
sessionStorage.setItem('loaded ', false)
$(window).on('load', function(){
lsessionStorage.setItem('loaded ', true)
});
if(lsessionStorage.loaded != true){
$(document.body).on("keydown", this, function(event) {
if(event.keyCode == 116){
alert('page is still loading . Please wait');
}
});
}
我正在glitch.com上托管该机器人。我正在向通道发送一条消息,然后将其编辑为包含请求数据的嵌入式消息。
(node:10860) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed.timestamp: Could not parse 1581492006141. Should be ISO8601.
at item.request.gen.end (/rbd/pnpm-volume/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
at then (/rbd/pnpm-volume/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
如果我发送嵌入消息而不是编辑上一条消息,则不会出错。我尝试解析时间戳,但它不接受。是因为上一封邮件的时间戳在发送后无法更改吗?
答案 0 :(得分:0)
您必须使用时间戳创建新的日期,Discord在此字段only ISO8601 date中不接受时间戳
您可以这样:
...
msg.channel.send("Recieving Data").then(response => {
//Get data
response.edit({
embed: {
description: "Example Data",
timestamp: msg.createdAt
}
})
}).catch(//handle error);
...
但是,如果您想使用一种快速简便的方法来设计嵌入,请尝试使用leovoel的此工具,Embed Visualizer会向您确切显示嵌入的外观,并在生成嵌入代码时按下一个按钮。这样,您将看到timestamp字段不接受时间戳。
答案 1 :(得分:-1)
您可以编辑embed timeStamp,但在解决方案中,您尝试仅使用timestamp字段编辑msg。所以你有一个错误。 msg.edit()
请勿更改内容的一部分,此方法将更改完整的邮件内容。
就像您已经嵌入description, footer, fields
一样。然后,您将使用仅 description
数据字段对其进行编辑,嵌入的其他字段也将被删除。
embed: {
//Data
description: "someText"
}
正确的方法是获取消息内容,嵌入和更改接收数据的嵌入时间戳,然后用新数据编辑消息。