await message confirm in plugin help

I'm not sure if this is the right place for this, but I'm trying to create a custom plugin for myself. essentially, one of the grating points for working in RPGmaker for me is doing all the clicking around to create dialog. What I'd like to do is have pre-created Js objects that I can load in with plugin commands. Eventually they'd be exported from a folder elsewhere and imported into the plugin file. But this is my current code.
JavaScript:
(function() {
    const dialogs = {}

    dialogs.testDialog = [
        {
            id: 1,
            text: "Hey you guys whazzup",
        },
        {
            id: 2,
            text: "Not much bro."
        }
    ]

    var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function (command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        if(command === "dialog") {
            const messages = dialogs[args[0]]
            console.log(messages)
            for (let message in messages) {
                talk = messages[message]
                Game_Interpreter.setWaitMode('message');
                $gameMessage.add(`${talk.id}: ${talk.text}`);
            }
        }

    }
})()

Basically what I'm running into is that it just adds each message to the current text box instead of waiting for the box to close and creating a new window. I've looked around but I haven't found any solutions. I just know that "setWaitMode" doesn't seem to work outside of script calls. I had considered awaiting a promise which would resolve when the current window is confirmed, but I can't seem to find documentation on the events that fire.

Can anyone help me figure out how to set the next window to wait on the current one?
Hi there!

I think, you can use $gameMessage.newPage() or just insert an escape code that jumps to another page.

Another thing would be doing this to refer to the current Game Interpreter:
this.setWaitMode('message');
instead of
Game_Interpreter.setWaitMode('message');

Or you could try calling the same Game Interpreter command that calls the default show text.
Just for the context:

Spoiler
JavaScript:
Game_Interpreter.prototype.executeCommand = function() {
    var command = this.currentCommand();
    if (command) {
        this._params = command.parameters;
        this._indent = command.indent;
        var methodName = 'command' + command.code;
        if (typeof this[methodName] === 'function') {
            if (!this[methodName]()) {
                return false;
            }
        }
        this._index++;
    } else {
        this.terminate();
    }
    return true;
};

Game_Interpreter.prototype.command101 = function() {
    if (!$gameMessage.isBusy()) {
        $gameMessage.setFaceImage(this._params[0], this._params[1]);
        $gameMessage.setBackground(this._params[2]);
        $gameMessage.setPositionType(this._params[3]);
        while (this.nextEventCode() === 401) {  // Text data
            this._index++;
            $gameMessage.add(this.currentCommand().parameters[0]);
        }
        switch (this.nextEventCode()) {
        case 102:  // Show Choices
            this._index++;
            this.setupChoices(this.currentCommand().parameters);
            break;
        case 103:  // Input Number
            this._index++;
            this.setupNumInput(this.currentCommand().parameters);
            break;
        case 104:  // Select Item
            this._index++;
            this.setupItemChoice(this.currentCommand().parameters);
            break;
        }
        this._index++;
        this.setWaitMode('message');
    }
    return false;
};

So maybe you could just take the command101 function, and replicate it in your own way.

Another thing you could look at to give you some light is this plugin:

It is in fact used to build a JSON file with texts to be used to translate a game.
So you attach the text to proper keys, similar to what you did, and just call these keys that they will be converted into a text.
Hi there!

I think, you can use $gameMessage.newPage() or just insert an escape code that jumps to another page.
Thanks! this did the trick. I can't believe it was that simple. I'm not new to programming but I am new to RPGmaker and the code and documentation can be thick and hard to find. Thanks for your help!

Original thread: https://forums.rpgmakerweb.com/threads/await-message-confirm-in-plugin-help.149866/