MZ Adding events to ... events ?

Hi!
I am currently trying to create a mini-game where you serves people, anyways so I'm creating a system.
When the mini game launch, some events are randomly taken and are added a emotion Bubble (Working fine) and I'm trying to add command in them.
I looked over there and located "Insert Event Command(s)"
When I'm making it in the editor using a script command, it work fine, but I can't make it work in the .js...
The log show me :
Code:
Command modifying : 6
OrderSystem.js:430 After adding new commands: (5) [{…}, {…}, {…}, {…}, {…}]0: code: 101indent: 0parameters: (4) ["", 0, 0, 0]__proto__: Object1: code: 401indent: 0parameters: ["\pop[6]Thanks, girl!"]__proto__: Object2: code: 230indent: 0parameters: [60]__proto__: Object3: code: 101indent: 0parameters: (4) ["", 0, 0, 0]__proto__: Object4: code: 401indent: 0parameters: ["Commande ajoutée avec succès !"]__proto__: Objectlength: 5__proto__: Array(0)
OrderSystem.js:433 Command and message added to Event ID: 6
So the list is written somewhere, but the event doesn't launch them currently.

Here is my function that is adding the command :

JavaScript:
function addPluginCommandToEvent(event, commandName, commandSpacedName) {
        console.log("Command add asked for :", event);
        if (!event || !event.page())
            return;
        if (!event._list || event._list.length === 0)
            event._list = []; // Initialise une liste vide
        
        console.log(`Command modifying : ${event.eventId()}`);

        const eventId = event.eventId();
        const i = 0; // Niveau d'indentation

        // Création des nouvelles commandes à insérer
        const com = [
            //{ code: 357, indent: i, parameters: [`${pluginName}`, `${commandName}`, `${commandSpacedName}`, { eventId: `${eventId}` }] },
            { code: 101, indent: i, parameters: ['', 0, 0, 0] }, // Ouvre la fenêtre de dialogue
            { code: 401, indent: i, parameters: [`\\pop[${eventId}]Thanks, girl!`] }, // Texte du message
            { code: 230, indent: i, parameters: [60] }, // Pause de 60 frames
            { code: 101, indent: i, parameters: ['', 0, 0, 0] }, // Ré-ouvre la fenêtre de dialogue
            { code: 401, indent: i, parameters: ['Commande ajoutée avec succès !'] } // Confirmation supplémentaire
        ];

        // Divise la liste de commandes actuelle autour du point d'exécution
        const pre = event._list.slice(0, event._index + 1); // Commandes avant le point actuel
        const post = event._list.slice(event._index + 1); // Commandes après
        
        event._list = pre.concat(com, post);
        console.log("After adding new commands:", event._list);
        
        // Rafraîchit l’événement pour inclure les nouvelles commandes
        console.log(`Command and message added to Event ID: ${eventId}`);
    }

I'm working on it since at least two hours and I can't find the problem here...
Does somebody more experimented than me could help me find why it doesn't work ?
The event are finded correctly, so I don't know from where is the error ... (actually it doesn't make an error, it just don't do anything)


Thanks a lot !
Is there some reason you can't just use the Common Event command?
After having a meal, I worked on it some more, and found what was wrong :
it's "event.page().list" and not "event._list"

Work fine now :
JavaScript:
function addPluginCommandToEvent(event, commandName, commandSpacedName) {
        console.log("Command add asked for :", event);
        if (!event || !event.page())
            return;
        if (!event._list || event._list.length === 0)
            event._list = []; // Initialise une liste vide
        
        console.log(`Command modifying : ${event.eventId()}`);

        const eventId = event.eventId();
        const i = 0; // Niveau d'indentation

        // Création des nouvelles commandes à insérer
        const com = [
            //{ code: 357, indent: i, parameters: [`${pluginName}`, `${commandName}`, `${commandSpacedName}`, { eventId: `${eventId}` }] },
            { code: 101, indent: i, parameters: ['', 0, 0, 0] }, // Ouvre la fenêtre de dialogue
            { code: 401, indent: i, parameters: [`\\pop[${eventId}]Thanks, girl!`] }, // Texte du message
            { code: 230, indent: i, parameters: [60] }, // Pause de 60 frames
            { code: 101, indent: i, parameters: ['', 0, 0, 0] }, // Ré-ouvre la fenêtre de dialogue
            { code: 401, indent: i, parameters: ['Commande ajoutée avec succès !'] } // Confirmation supplémentaire
        ];

        // Divise la liste de commandes actuelle autour du point d'exécution
        const pre = event.page().list.slice(0, event._index + 1); // Commandes avant le point actuel
        const post = event.page().list.slice(event._index + 1); // Commandes après
        
        event.page().list = pre.concat(com, post);
        console.log("After adding new commands:", event.page().list);
        
        // Rafraîchit l’événement pour inclure les nouvelles commandes
        console.log(`Command and message added to Event ID: ${eventId}`);
    }


To answer caethyril, I wanted to manually add the commands to the event because I randomly add them to a percentage of events, on an event array stored in the script.

And also I like to complicate my life 😀

​

Original thread: https://forums.rpgmakerweb.com/threads/adding-events-to-events.174358/