// removepoints.js
import { QuickDB } from "quick.db";

const db = new QuickDB();

export default {
  name: "removepoints",
  description: "إزالة نقاط عضو (أدمن فقط)",
  async execute(message, args, ctx) {
    const { getPointsOf, setPointsOf, config } = ctx;

    // صلاحية الأدمن
    if (!message.member.roles.cache.some(r => (config.adminRoles || []).includes(r.id))) {
      return message.reply("❌ معندكش صلاحية.");
    }

    const member = message.mentions.members.first();
    if (!member) return message.reply("❗ منشن العضو.");

    const removePoints = parseInt(args[1]);
    if (isNaN(removePoints)) return message.reply("❗ استخدم: !removepoints @user <عدد>");

    const oldPoints = await getPointsOf(message.guild.id, member.id);
    const newPoints = Math.max(0, oldPoints - removePoints);

    await setPointsOf(message.guild.id, member.id, newPoints);

    message.reply(`🗑️ تم إزالة ${removePoints} نقطة من ${member.user.tag}. المجموع الآن: ${newPoints}`);
  }
};
