How can I create an embeddedCollection in a chat message?

I have this:
const messageDocument = game.messages.get(message._id);
const doc = new TJSDocument(messageDocument);
doc.embedded.create("Targets", targets);
const messageDocument = game.messages.get(message._id);
const doc = new TJSDocument(messageDocument);
doc.embedded.create("Targets", targets);
But I think that might be creating a clone rather than updating the original message?
1 Reply
TyphonJS (Michael)
You can certainly learn more about how Foundry works itself. There are no embedded collections on chat messages as far as I know. Embedded collections in the core document model are set in advance. You can't just randomly add or create a new embedded collection on a document that is not configured to have any. Create on the sense of reactive embedded collections "creates" the reactive binding, but a collection type must already exist on the document.