2

Enhance UserMessageCallback for Advanced Scripting and Moderation

Suggested by
on May 13, '26
Open

The UserMessageCallback system is currently too limited to support many common scripting use cases, particularly chat moderation.

Although the callback provides useful information such as the sender, the full message, and parsed command components, it is strictly observational. Scripts can detect messages, but they have no ability to modify, suppress, or intercept them before they are shown to other players.

This limitation makes it impossible to implement even basic moderation features, such as:

  • Blocking messages containing banned words.
  • Filtering spam or repeated messages.
  • Preventing advertising or malicious links.
  • Replacing inappropriate content.
  • Implementing custom chat rules.
  • Silencing specific users under script control.

As a result, scripters who want to create moderation tools, chat filters, or advanced command systems are unable to do so effectively.

A more powerful callback system should allow scripts to influence how messages are processed. The most useful addition would be a property such as:

public bool Cancel { get; set; }

When set to true, the message would not be displayed or further processed by the game.

Another valuable improvement would be to allow modification of the message itself:

public string Message { get; set; }

This would enable scripts to sanitize content, rewrite text, or implement custom formatting before the message is sent.

With these additions, moderation scripts could be implemented in a straightforward way:

private void OnUserMessage(UserMessageCallbackArgs args)
{
    if (ContainsBannedWord(args.Message))
    {
        args.Cancel = true;
        Game.ShowChatMessage(
            "Your message contains prohibited content.",
            Color.Red,
            args.User.UserIdentifier
        );
    }
}

Additional properties that could further improve the API include:

  • bool Handled to prevent other callbacks from processing the same message.
  • DateTime Timestamp to assist with rate limiting and spam detection.
  • string OriginalMessage to preserve the unmodified text when Message is editable.

Watchers

No comments yet.
Loading comments...
Loading comments...
0 comments loaded

Sign in to comment on this suggestion. Sign In