Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clickable text and hover text #2529

Merged
merged 1 commit into from
Oct 5, 2024
Merged

Add clickable text and hover text #2529

merged 1 commit into from
Oct 5, 2024

Conversation

tastybento
Copy link
Member

Method: sendRawMessage

Sends a raw message to the sender, parsing inline commands embedded within square brackets.

The method supports embedding clickable and hoverable actions into the message text using inline commands. Recognized commands are:

  • [run_command: <command>] - Runs the specified command when the message is clicked.
  • [suggest_command: <command>] - Suggests the specified command in the chat input.
  • [copy_to_clipboard: <text>] - Copies the specified text to the player's clipboard.
  • [open_url: <url>] - Opens the specified URL when the message is clicked.
  • [hover: <text>] - Shows the specified text when the message is hovered over.

The commands can be placed anywhere in the message and will apply to the entire message component. If multiple commands of the same type are provided, only the first one encountered will be applied. Unrecognized or invalid commands enclosed in square brackets will be preserved in the output text.

Example usage:

sendRawMessage("Hello [not-a-command: hello][run_command: /help] World [hover: This is a hover text]");

The above message will display:

Hello [not-a-command: hello] World
  • Click Event: Runs the /help command when clicked.
  • Hover Event: Shows "This is a hover text" when hovered.

@tastybento
Copy link
Member Author

Also removed debug.

@tastybento tastybento merged commit 97aff7a into develop Oct 5, 2024
1 check failed
@tastybento tastybento deleted the clickable_text branch October 5, 2024 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant