Chat Metadata
Certain chat cards have metadata attached to them. Assuming you have an instance
of ChatMessagePF from somewhere (such as game.messages.get()
), you can use
the following function to retrieve the metadata:
msg.getFlag("pf1", "metadata")
Not all messages have this metadata object. For those that do, assume the following interface (written as if per TypeScript):
interface DamageRoll {
damageType: string;
roll: RollJSON;
}
interface ChatMetadata_Rolls_Attack {
attack?: RollJSON;
critConfirm?: RollJSON;
damage?: { [k: number]: DamageRoll; };
critDamage?: { [k: number]: DamageRoll; };
}
interface ChatMetadata {
item: string;
template?: string;
rolls?: {
attacks?: { [k: number]: ChatMetadata_Rolls_Attack; };
};
}
In the above interfaces, you will notice a RollJSON
interface that doesn’t
get declared. This is actually a result of Roll.toJSON()
from the base
FoundryVTT application.
In ChatMetadata
, the item
and template
keys store the item and
measured template ID associated with the chat card.