mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
22 lines
742 B
JavaScript
22 lines
742 B
JavaScript
import DHBaseAction from './baseAction.mjs';
|
|
|
|
export default class DHMacroAction extends DHBaseAction {
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields;
|
|
return {
|
|
...super.defineSchema(),
|
|
documentUUID: new fields.DocumentUUIDField({ type: 'Macro' })
|
|
};
|
|
}
|
|
|
|
async trigger(event, ...args) {
|
|
const fixUUID = !this.documentUUID.includes('Macro.') ? `Macro.${this.documentUUID}` : this.documentUUID,
|
|
macro = await fromUuid(fixUUID);
|
|
try {
|
|
if (!macro) throw new Error(`No macro found for the UUID: ${this.documentUUID}.`);
|
|
macro.execute();
|
|
} catch (error) {
|
|
ui.notifications.error(error);
|
|
}
|
|
}
|
|
}
|