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]})
}
}
}
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]})
}
}
}
3 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.We do not provide help with unrelated stuff.
#useful-servers