【发布时间】:2020-05-27 17:26:46
【问题描述】:
尝试使用 discord.js 将不和谐消息编辑为 RichEmbedded 消息时,我收到错误消息
(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)
我在 glitch.com 上托管该机器人。我正在向频道发送消息,然后将其编辑为包含请求数据的嵌入式消息。
msg.channel.send("Recieving Data").then(response => {
//Get data
response.edit({
embed: {
description: "Example Data",
timestamp: msg.createdTimestamp
}
})
}).catch(//handle error);
如果我发送嵌入消息而不是编辑以前的消息,它不会出错。我试过解析时间戳但它不接受它。是不是因为上一条消息发送后时间戳无法更改?
【问题讨论】:
-
在 Discord 中,embed 的时间戳是 ISO8601 时间戳,discord.js 在 createdTimestamp 上是否也使用 ISO8601 时间戳?否则,您必须在时间戳末尾添加 3 个“0”
-
@ShigehiroKamisama 据我了解,createdTimestamp 将 UNIX 时间作为数值(即 1581532642193)给出,正常解析它没有问题,但如果我使用嵌入编辑之前的消息,它会出现问题。
标签: node.js discord discord.js