blacklist system not working

const { model, Schema } = require('mongoose');
 
let blacklist = new Schema({
    User: String
});
 
module.exports = model('blacklist', blacklist);


const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const blacklist = require('../../models/blacklist');
 
module.exports = {
    data: new SlashCommandBuilder()
    .setName('blacklist')
    .setDescription('Blacklist a user from using this bot')
    .addSubcommand(command => command
        .setName('add')
        .setDescription('Add a user to the blacklist')
        .addStringOption(option => option
            .setName('user')
            .setDescription('The user ID you want to blacklist')
            .setRequired(true)
            )
    )
    .addSubcommand(command => command
        .setName('remove')
        .setDescription('Remove a user from the blacklist')
        .addStringOption(option => option
            .setName('user')
            .setDescription('The user ID you want to remove from the blacklist')
            .setRequired(true)
            )
    ),
    async execute(interaction) {
 
        const { options } = interaction;
        if(interaction.user.id !== '778992675830759455') return await interaction.reply({ content: `Only cyukizzz can use this command!`, ephemeral: true });
 
        const user = options.getString('user');
        const data = await blacklist.findOne({ User: user });
        const sub = options.getSubcommand();
 
        switch(sub) {
            case 'add':
 
            if(!data) {
                await blacklist.create({
                    User: user,
                })

                
 
                const embed = new EmbedBuilder()
                .setColor('Red)
                .setDescription(` \`${user}\` has been blacklisted from using my commands.`)
                .setTimestamp()
 
                await interaction.reply({ embeds: [embed] });
            } else if(data) {
                return await interaction.reply({ content: `The user \`${user}\` has already been **blacklisted**`, ephemeral: true })
            }
 
            break;
            case 'remove':
                if(!data) {
                    return await interaction.reply({ content: `The user \`${user}\` is not on the **blacklist**`, ephemeral: true })
                } else if(data) {
                    await blacklist.deleteMany({ User: user });
 
                    const embed = new EmbedBuilder()
                    .setColor('Green')
                    .setDescription(`\`${user}\` has been removed from the blacklist.`)
                    .setTimestamp()
 
                    await interaction.reply({ embeds: [embed], ephemeral: true });
        }
    }
}
}


client.on(Events.InteractionCreate, async interaction => {
  const blacklist = require('./models/blacklist');
  const data = await blacklist.findOne({ User: interaction.user.id });

  if(data) {
    return await interaction.reply({ content: `You have been **blacklisted** from using this bot! This means the developer doesn't want you to use it's commands for any given reason`, ephemeral: true })
  }

  if (!data)
  return;
})


it says the user is blacklisted but the commands are still running for them
Was this page helpful?