What event should I be using to detect messages added by the custom javascript code?

I am working on something with the custom javascript code in the advanced character chat that relies on activating when another function in that same code block pushes a message to the thread with thread.messages.push, and I have tried the MessageAdded event, but it isn’t working for some reason. What should I be doing instead? (And yes, I have verified that it just isn’t detecting it, rather than being a separate issue).

1 points · 4 comments · view on lemmy.world

4 Comments

Adventurous_Step2911@lemmy.world · 1 pts · 9d (3 replies)

Why do you even need any event? You add the message programmatically, so you know exactly when it is added

Maidens_Against_Zeus@lemmy.world · 1 pts · 9d (2 replies)

Because I am still figuring things out, since I am VERY new to javascript. With my current understanding of things, the way I am doing it is the only way I can wrap my brain around.

Adventurous_Step2911@lemmy.world · 1 pts · 9d (1 reply)

That's fine, try something like this:

thread.messages.push(message);
yourCustomFunction(message);

Let me know if this is what you want or not, or send me your code

Maidens_Against_Zeus@lemmy.world · 2 pts · 9d

It kinda worked. Thanks.