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

199
Views
discordjs v13 - resta la variable

El código no funciona cuando resta la variable (salud del enemigo)

este es mi codigo

 if (message.content === ".battle") { //hidden code.... let damage = Math.floor(Math.random() * 10) let user = message.author let embed = new Discord.MessageEmbed() .setTitle(`${user.username}'s battle`) .setColor("GREEN") .setDescription(` **${user.username}'s Stats** Health: ${player_health} Mana: ${player_mana} Power: ${power} Frist Skill: ${a1} Second Skill: ${a2} Third Skill: ${a3} `) //enemy embed let ene_health = 100 let ene_xp = 10 let embed1 = new Discord.MessageEmbed() .setTitle(`${user.username}'s battle`) .setDescription(` **Enemy's Stats** Health: ${ene_health} Mana: ${ene_mana} `) const row = new MessageActionRow() .addComponents( new MessageButton() .setCustomId('primary') .setLabel(`Use: ${power}`) .setStyle('PRIMARY'), ); //hidden code...... await message.reply({ content: "You have 1 minute to choose the skills", embeds: [embed, embed1], components: [row] }); const filter = i => i.customId === 'primary' && i.user.id === `${message.author.id}`; const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 }); collector.on('collect', async i => { if (i.customId === 'primary') { await i.deferUpdate(); await wait(4000); await i.editReply({ content: `You've use ${power} power and you deal the ${damage} Dmg.`, components: [] }) //there the problem damage - ene_health } }); collector.on('end', collected => console.log(`Collected ${collected.size} button`)); }

Me pregunto por el damage - ene_health porque no le resta salud al enemigo

estoy usando discord.js v13 y quickdb

debe restar la salud del enemigo pero no restará

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

damage - ene_health

no esta haciendo nada En tu caso tienes que CAMBIAR la variable de daño.

 damage = damage - ene_health

o incluso mejor, use la Substract assignment :

 damage -= ene_health
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!