const { SlashCommandBuilder } = require('discord.js'); const { ownerID } = require('../../config.json'); const fs = require('fs'); module.exports = { data: new SlashCommandBuilder() .setName('whitelist') .setDescription('Add user to whitelist') .addUserOption(option => option .setName('target') .setDescription('The member to whitelist') .setRequired(true)), async execute(interaction) { const userID = interaction.user.id; // This is the ID of the user who triggered the interaction if (userID.localeCompare(ownerID)) { const target = interaction.options.getUser('target'); const config = JSON.parse(fs.readFileSync('config.json', 'utf-8')); if (!config.whitelist.includes(target.id)) { // Add the user ID to the whitelist config.whitelist.push(target.id); // Write the updated JSON back to the config file fs.writeFileSync('config.json', JSON.stringify(config, null, 2)); await interaction.reply('User has been added to the whitelist!'); } else { await interaction.reply('User is already in the whitelist!'); } } else { await interaction.reply('You\'r not the owner of the bot!'); } }, };