32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
const { SlashCommandBuilder } = require('discord.js');
|
|
const { simpleEmbed } = require('../functions/embeds.js');
|
|
const { Minecraft, Users } = require('../functions/models.js');
|
|
const { applyUsername } = require('../functions/utils.js');
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('removewhitelist')
|
|
.setDescription('Remove yourself from the whitelist'),
|
|
|
|
async execute(interaction) {
|
|
try {
|
|
const user = await Users.findOne({ where: { id: interaction.user.id } });
|
|
|
|
if (!user.minecraftUUID) return await interaction.reply({ embeds: [simpleEmbed('You are not whitelisted')], ephemeral: true });
|
|
|
|
await Minecraft.destroy({ where: { uuid: user.minecraftUUID } });
|
|
user.minecraftUUID = '';
|
|
|
|
await user.save();
|
|
|
|
await applyUsername(user, interaction.member);
|
|
|
|
await interaction.reply({ embeds: [simpleEmbed('Successfully removed you from the whitelist')], ephemeral: true });
|
|
} catch (error) {
|
|
console.error(error);
|
|
|
|
await interaction.reply({ embeds: [simpleEmbed('There was an error while removing you from the whitelist')], ephemeral: true });
|
|
}
|
|
},
|
|
};
|