mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
20 lines
587 B
JavaScript
20 lines
587 B
JavaScript
const fields = foundry.data.fields;
|
|
|
|
export default class MacroField extends fields.DocumentUUIDField {
|
|
order = 70;
|
|
|
|
constructor(context = {}) {
|
|
super({ type: "Macro" }, context);
|
|
}
|
|
|
|
async execute(config) {
|
|
const fixUUID = !this.macro.includes('Macro.') ? `Macro.${this.macro}` : this.macro,
|
|
macro = await fromUuid(fixUUID);
|
|
try {
|
|
if (!macro) throw new Error(`No macro found for the UUID: ${this.macro}.`);
|
|
macro.execute();
|
|
} catch (error) {
|
|
ui.notifications.error(error);
|
|
}
|
|
}
|
|
}
|