Database Error

const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const profileModel = require('../Economy/profiles');
module.exports = {
    data: new SlashCommandBuilder()
    .setName('work')
    .setDescription('Work to earn yourself a little bit of Kai.'),
    version: "1.0.0",
    async execute(interaction, profileData){
        const kai = ':Kai:'
        const amount = Math.floor(Math.random() * 500) + 1;
        const number = Math.floor(Math.random() * 300) + 1;
        if (amount < 200){
            const final = 200 + number
            const response = await profileModel.findByIdAndUpdate({
                userID: interaction.user.id
            }, {
                $inc: {
                    kai: final
                },
            });
            const workFEmbed = new EmbedBuilder()
            .setColor('#0099ff')
            .setTitle('Work')
            .setDescription(`You worked and received ${final} ${kai}.`)
            return interaction.reply({ embeds: [workFEmbed]})
        } else {
            const final = amount
            const response = await profileModel.findOneAndUpdate({
                userID: interaction.user.id
            }, {
                $inc: {
                    kai: final
                },
            });
            const workFEmbed = new EmbedBuilder()
            .setColor('#0099ff')
            .setTitle('Work')
            .setDescription(`You worked and received ${final} ${kai}.`)
            return interaction.reply({ embeds: [workFEmbed]})
        }
    }
}
Was this page helpful?