discordjs v13 - 减去变量

discordjs v13 - subtract the variable

代码在减去变量(敌人的生命值)时不起作用

这是我的代码

 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`));
    }

我想知道damage - ene_health为什么它不减去敌人的生命值

我正在使用 discord.js v13 和 quickdb

damage - ene_health

没有做任何事情。在您的情况下,您必须更改损坏变量。

damage = damage - ene_health

甚至更好,使用 Substract assignment :

damage -= ene_health