Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
Mongo DB | El comando discord.js Add-Money no funciona

Estoy haciendo un comando Add-money de Discord.js pero tiene un error extraño. Siempre que ejecuto este comando ?add-money 1 entonces funciona perfectamente bien pero cuando lo ejecuto de nuevo escribiendo ?add-money 1 entonces en lugar de eso para que mi saldo llegue a 2, lo hace a 11, lo que literalmente no tiene sentido, por favor ayuda con mi problema.

aquí está el código:

 const { MessageEmbed, MessageButton, MessageActionRow } = require(`discord.js`); const ee = require(`../../botconfig/embed.json`); const User = require("../../models/user.js") module.exports = { name: `add-money`, run: async (client, message, args) => { if(!message.member.permissions.has("ADMINISTRATOR") return message.channel.send("You Dont Have Required Perms to Run This Command!") let user = await User.findOne({ id: message.author.id }) if(!user) return message.channel.send(`You Dont own a Account yet!`) let amount = args[0] if(Number.isNaN(+amount)) return message.channel.send(`The amount is Not A Number!`) user.coins = user.coins + amount await user.save() return message.channel.send(`You added ${amount} to your balance!`) } }

Aquí está mi modelo de mangosta:

 const mongoose = require("mongoose"); const UserSchema = new mongoose.Schema({ id: { type: String, required: true }, coins: { type: Number, default: 0 }, }); module.exports = mongoose.model("User", UserSchema);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

user.coins += Math.floor(amount) await user.save();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!