Skip to content
Functiondiscord-component-embedv1.0.0

toComponentEmbed

Converts a Container tree into the JSON document Discord reads for a component embed. To write the JSON into a page, use toComponentEmbedJson or toComponentEmbedScript. Both escape it for a <script> tag.

Throws:

  • a ComponentEmbedError when the tree breaks a rule of the format, or when your own code throws while the package reads it. Check error.code to see which.

toComponentEmbed(root: EmbedElement): ComponentEmbedPayload