'Is there a way to set the timestamp to UTC in discord.js
I wanted to create a footer for a discord embed, that has UTC time so I created the lines in the following, and then it errored a lot, so I turned it into an object / {}. Then I got this " if (typeof data !== 'string') throw new error(errorMessage); ^ RangeError [EMBED_FOOTER_TEXT]: MessageEmbed footer text must be a string. at reply (C:\Users\Eb482\OneDrive\Desktop\bot\app.js:219:10)" here is my code
let embed = new MessageEmbed()
.setColor('RANDOM')
.setThumbnail(serverIcon)
.setTitle(message)
.setFooter({name: new Date(Date.now()).toISODateString})
.setAuthor(author1);
if (Fields) embed = embed.setFields(Fields);
if (EmbedFile) embed = embed.setImage(EmbedFile);
interaction.reply({ embeds: [embed], ephemeral: ephemeral, components: components });
}
Please if anyone knows how to fix the error let me know.(on discord v13)
Solution 1:[1]
add .setTimestamp();
after the setAuthor, it would show the user their local time
let embed = new MessageEmbed()
.setColor('RANDOM')
.setThumbnail(serverIcon)
.setTitle(message)
.setFooter({name: new Date(Date.now()).toISODateString})
.setAuthor(author1)
.setTimestamp();
if (Fields) embed = embed.setFields(Fields);
if (EmbedFile) embed = embed.setImage(EmbedFile);
interaction.reply({ embeds: [embed], ephemeral: ephemeral, components: components });
}
Solution 2:[2]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Finn-Dev |
Solution 2 | Neenhila |