ChatPatches icon indicating copy to clipboard operation
ChatPatches copied to clipboard

Idea: Custom scripts

Open LWJENNI opened this issue 8 months ago • 1 comments

šŸ“Œ Feature Proposal: Custom Script Support for ChatPatches

Hi!
I’d like to suggest an idea for the ChatPatches mod — adding support for custom scripts for client-side chat message handling.


šŸ“– Idea:

Introduce support for writing custom JavaScript scripts that can handle client-side events like:

  • Receiving chat messages
  • Displaying boss bars
  • Handling titles
  • Scoreboard updates

This system would allow players to:

  • Automatically remove ads or unwanted messages from the chat
  • Hide boss bars or titles based on conditions
  • Filter messages by keywords
  • Customize how chat messages appear

šŸ“ How It Could Work:

  • Add a "Scripts" section in the mod settings, where players can:

    • Create new scripts (with a custom name)
    • Edit the script code (written in JavaScript)
    • Delete scripts
    • Enable/disable scripts individually
    • Specify the server IP where each script should be active
  • Provide built-in documentation listing the available API methods and events, for example:

    • onChatMessage(callback)
    • getServerIp()
    • event.message
    • event.remove()
    • and others

šŸ“¦ Example Use Case:

A player could write a script like this:

onChatMessage(function(event) {
    if (getServerIp() === "example.net") {
        if (event.message.includes("advertisement")) {
            event.remove();
        }
    }
});

This would automatically remove any chat message containing the word "advertisement" when connected to "example.net".

Optionally, it could capture the next 5 messages or perform additional actions.


šŸ“Œ Why This Would Be Useful:

  • It gives players a flexible, scriptable way to control their client chat experience.
  • Users could tailor chat behavior to specific servers.
  • Can help block spam, manage boss bars, or automate message formatting.
  • No need to edit mod code — scripts are fully managed through the UI.

I’m not sure how exactly to implement this yet, but I’d love to see a feature like this added to ChatPatches.

LWJENNI avatar Jun 12 '25 11:06 LWJENNI

this is a cool idea!! while it's definitely not in scope at the moment, i think down the road i could look into something like providing native integration with KubeJS to accomplish this.

mrbuilder1961 avatar Jun 12 '25 15:06 mrbuilder1961