Skip to content
Functiondiscord-component-embedv1.0.0

fromPayload

Turns a component embed's JSON back into a tree. Use it to check JSON you wrote by hand or got from somewhere else. Pass the result to toComponentEmbed or toComponentEmbedJson. They throw the same errors they throw for a tree built with JSX.

Throws:

  • a ComponentEmbedError when the JSON can't become a tree, like a component with a type no embed allows or a separator spacing other than 1 or 2. Its path lists the JSON keys that lead to the problem.

fromPayload(payload: ComponentEmbedPayload): EmbedElement