chore: Add initial configuration files and code structure

This commit is contained in:
Bildcraft1 2024-06-05 22:06:30 +02:00
commit 127a7dc87f
13 changed files with 1761 additions and 0 deletions

View file

@ -0,0 +1,35 @@
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!');
}
},
};