export type CommandGateReason =
  | 'disabled'
  | 'channel_denied'
  | 'channel_not_allowed'
  | 'role_denied'
  | 'role_not_allowed'
  | 'cooldown';

export function isChannelAllowed(
  channelId: string | null,
  allowed: string[],
  denied: string[]
): CommandGateReason | null {
  if (!channelId) {
    return null;
  }
  if (denied.includes(channelId)) {
    return 'channel_denied';
  }
  if (allowed.length > 0 && !allowed.includes(channelId)) {
    return 'channel_not_allowed';
  }
  return null;
}

export function isRoleAllowed(
  roleIds: string[],
  allowed: string[],
  denied: string[]
): CommandGateReason | null {
  if (denied.some((id) => roleIds.includes(id))) {
    return 'role_denied';
  }
  if (allowed.length > 0 && !allowed.some((id) => roleIds.includes(id))) {
    return 'role_not_allowed';
  }
  return null;
}
