I have a Discord.js Message instance, which, as defined in the documentation, should have a .cleanContent
property, and it should be a string.
console.log(message.cleanContent)
works as intended, but
console.log(message)
does not log thecleanContent
property.- More so,
Object.keys(message)
does not discover thecleanContent
property. - However,
JSON.parse(JSON.stringify(message))
has a loggable, visiblecleanContent
in turn. - A
for(key in message)
loop also does not list the.cleanContent
.
So, uh.. what is going on here?
The bug is reproducable with this much code:
client.on("messageCreate", (message) => {
console.log(Object.keys(message))
})
CodePudding user response:
This is due to the fact that it's a getter, as shown here. Getters don't seem to be logged in node.js, unlike in my browser's developer console (Chrome). Getters are different in different environments, so it's difficult to provide a solution.