const fs = require('fs'); const path = require('path'); const { BOT_OWNER_ID } = require('../config.json'); module.exports = { name: 'blacklist', description: 'Blacklist or unblacklist a user from using the bot', async execute(message, args) { if (message.author.id !== BOT_OWNER_ID) { return message.reply("You don't have permission to use this command."); } const mentionedUser = message.mentions.users.first(); if (!mentionedUser) { return message.reply("Please mention a user to blacklist/unblacklist."); } const blacklistPath = path.join(__dirname, '../blacklist.json'); const blacklistData = JSON.parse(fs.readFileSync(blacklistPath, 'utf8')); const isBlacklisted = blacklistData.blacklisted.includes(mentionedUser.id); if (isBlacklisted) { blacklistData.blacklisted = blacklistData.blacklisted.filter(id => id !== mentionedUser.id); fs.writeFileSync(blacklistPath, JSON.stringify(blacklistData, null, 2)); message.reply(`${mentionedUser.tag} has been unblacklisted.`); } else { blacklistData.blacklisted.push(mentionedUser.id); fs.writeFileSync(blacklistPath, JSON.stringify(blacklistData, null, 2)); message.reply(`${mentionedUser.tag} has been blacklisted.`); } const updatedBlacklist = blacklistData.blacklisted; const index = require('../index.js'); index.updateBlacklist(updatedBlacklist); } };