import type { ChannelStatus, ChatSender } from "../types.ts";

export type ModerationTarget = ChatSender & { protected?: boolean };

export class ModeratorGuard {
  assertAllowed(channel: ChannelStatus, target: ModerationTarget, simulation: boolean): void {
    if (simulation) return;
    if (channel.moderator_status !== "moderator") {
      throw new Error("Action de modération bloquée : rôle fiIyx non confirmé.");
    }
    if (target.kick_user_id === channel.kick_user_id || target.roles.includes("owner") || target.roles.includes("broadcaster")) {
      throw new Error("Action de modération bloquée : le propriétaire est protégé.");
    }
    if (target.protected) {
      throw new Error("Action de modération bloquée : utilisateur protégé.");
    }
  }
}

