Markoudstaal / node-red-contrib-discord-advanced

Recieve, send, edit and delete Discord messages in node-red.
MIT License
46 stars 16 forks source link

TypeError: Do not know how to serialize a BigInt #24

Closed mateusrovedaa closed 2 years ago

mateusrovedaa commented 2 years ago

When I use the interaction node to listen a button interaction, an error is being returned:

[red] Uncaught Exception:
[error] TypeError: Do not know how to serialize a BigInt
at stringify (<anonymous>)
at Object.stringify (/data/node_modules/flatted/cjs/index.js:76:17)
at Client.<anonymous> (/data/node_modules/node-red-contrib-discord-advanced/discord/discordInteraction.js:64:49)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

image

The flow I'm trying to use is the same as the example provided here on the Wiki, both the one that sends the message and creates with the buttons and the one that listens for an interaction.

I think this problem happens with commands too.

javis86 commented 2 years ago

I'm facing how to resolve this because with my actual environment of node-red interactionObject serialize ok. But testing outside i got this error. A quickest way is adding

BigInt.prototype.toJSON = function () {
    return this.toString()
}

at the top of lib/discordBotManager