Can someone check a line of javascript for me? I feel like it should work.

So, brief summary. I have a character with some aggressive abilities that, in addition to other effects, buff their own attack and debuff their own defense, making them more dangerous and more fragile as the battle goes on.

I was hoping to give them an ability with low base damage that, if it kills an enemy, heals them a small amount and removes all of their currently ongoing defense debuffs.

I have Yanfly's Skill Core plugin in order to insert javascript into skills. My notebox currently reads:

<Post-Damage Eval>
if (target.hp <= 0) {
user.gainHp(50);
user.removeDebuff(3);
}
</Post-Damage Eval>

So, in theory, this should deal the skill's damage, then evaluate if the target's HP is 0 or less. If it is, the user of the skill gains 50hp and removes their defense debuffs. When I use the skill and it doesn't kill an enemy, everything is fine. When I use the skill and it kills an enemy, the game gets an error and the javascript effects do not trigger. If I remove the "user.removeDebuff(3)" part, it works fine. If it switch it to "user.removeBuff(3)", that works fine.

So, I assume I'm somehow writing "user.removeDebuff(3)" incorrectly? It's driving me a little insane.
Forgive my ignorance as I haven't used this particular plugin, but I'll give it a try anyways. I looked through the YEP Skill Core, YEP Buffs & States plugin, and the core RMMV code, and I didn't see a "removeDebuff" or "removeBuff" function defined anywhere.

1.) Where did you learn that these functions are defined to use? If it's another plugin, please provide the link and I can read the code for you to try to find out what is happening.

2.) When the game errors, please press F8 and post a screenshot of the full error message.

Edit: As caethyril points out below, "removeBuff" is indeed defined in the core RMMV code.
In the base code: removeDebuff does not exist, but removeBuff does (it's defined in rpg_objects.js). Basically, removeBuff just sets the magnitude and duration of the specified parameter's buff to 0. A debuff is simply a negative buff magnitude; you can't be buffed and debuffed at the same time. (If you want that sort of effect, consider using states as "fake" debuffs instead.)

You could try something like this:
Code:
<Post-Damage Eval>
if (target.hp <= 0) {
  user.gainHp(50);
  if (user.isDebuffAffected(3)) {
    user.removeBuff(3);
  }
}
</Post-Damage Eval>
isDebuffAffected is a function defined in rpg_objects.js, and does what you'd expect. =)
Thank you both! I tried your solution, caethyril, and it worked perfectly. I just assumed that since 'Debuff' is used in other contexts, it would be used in all contexts, and obviously that was wrong. I appreciate the help and also pointing me at rpg_objects.js, which I'm sure will solve several future headaches preemptively. =)

Original thread: https://forums.rpgmakerweb.com/threads/can-someone-check-a-line-of-javascript-for-me-i-feel-like-it-should-work.94794/