chore: Add initial configuration files and code structure
This commit is contained in:
commit
127a7dc87f
13 changed files with 1761 additions and 0 deletions
35
commands/utility/whitelist.js
Normal file
35
commands/utility/whitelist.js
Normal 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!');
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue