// SPDX-FileCopyrightText: 2021 Johannes Loher
//
// SPDX-License-Identifier: MIT

import { notifications } from "../ui/notifications";
import { getGame } from "../utils/utils";
import { getActiveActorAndToken } from "./helpers";

/**
 * Executes the roll generic check macro.
 */
export async function rollGenericCheck(): Promise<void> {
  const { actor, token } = getActiveActorAndToken();
  if (!actor) {
    return notifications.warn(getGame().i18n.localize("DS4.WarningMustControlActorToUseRollCheckMacro"));
  }

  return actor.rollGenericCheck({ speaker: { token } }).catch((e) => notifications.error(e, { log: true }));
}
