How do I indicate that I want something to run only when the player uses the plugin command?

So I'm sure this is a simple thing, and I've looked through other plugins to see if I could figure it out, but I must be missing it because I can't see what tells the code to run only once called via a plugin command?

To make sure I'm clear enough, basically, I'm writing a card mini-game, and I'd like for it to be called when a player adds the plugin command "Monster Fighter", (The name of my card game.) to an event.

Any help here is greatly appreciated.
Plugin Command invokes the pluginCommand method of Game_Interpreter. You can alias this method and check the input against your plugin's specific notation, e.g.
JavaScript:
// Plugin command handler
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;  // alias
Game_Interpreter.prototype.pluginCommand = function(command, args) {  // replace method
    _Game_Interpreter_pluginCommand.call(this, command, args);  // invoke original method
    if (command.toUpperCase() === 'MONSTER_FIGHTER') {  // check for your plugin command
        // do stuff!
    }
};
Note that a plugin command comprises a number of "words" split by spaces:
  • command is the first word, often used to determine which plugin the command is for.
  • args is an array containing all the subsequent words, in order. These can be used to refine the command, e.g.
    JavaScript:
    if (args[0].toUpperCase() === 'TRUE') { // first argument is "true"?
    // do stuff~
    }
    Sounds like you just want a simple thing though, so you probably won't need to worry about the args. 🙏
Plugin Command invokes the pluginCommand method of Game_Interpreter. You can alias this method and check the input against your plugin's specific notation, e.g.
JavaScript:
// Plugin command handler
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;  // alias
Game_Interpreter.prototype.pluginCommand = function(command, args) {  // replace method
    _Game_Interpreter_pluginCommand.call(this, command, args);  // invoke original method
    if (command.toUpperCase() === 'MONSTER_FIGHTER') {  // check for your plugin command
        // do stuff!
    }
};
Note that a plugin command comprises a number of "words" split by spaces:
  • command is the first word, often used to determine which plugin the command is for.
  • args is an array containing all the subsequent words, in order. These can be used to refine the command, e.g.
    JavaScript:
    if (args[0].toUpperCase() === 'TRUE') { // first argument is "true"?
    // do stuff~
    }
    Sounds like you just want a simple thing though, so you probably won't need to worry about the args. 🙏
Thank you very much, this is exactly what I was looking for!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-indicate-that-i-want-something-to-run-only-when-the-player-uses-the-plugin-command.116370/