How to use /tellraw with a clickEvent to set up another /tellraw clickEvent? [closed]

Solution 1:

You technically can, but there are two main obstacles:

  1. Nesting JSON inside of JSON (or any text format inside of any text format, really) gets ugly fast.
                    JSON:  {"text":"Hello"}
            JSON in JSON:  {"text":"{\"text\":\"Hello\"}"}
    JSON in JSON in JSON:  {"text":"{\"text\":\"{\\\"text\\\":\\\"Hello\\\"}\"}"}
    
  2. Click events are run as if they had been typed into the command line by the player who clicked them. This means that, if the player is not an operator, they will not be able to run commands like /tellraw. Also, if the command is too long, it will get cut off, which can be a problem because of (1).

So yes, but it'll be ugly and it won't work if the person clicking isn't an operator. You can get around both of these using /trigger.

/trigger is a command designed to allow non-op players to interact with command systems in a safe, controlled manner. It can take three forms:

/trigger <objective> set <number>
/trigger <objective> add <number>
/trigger <objective>               <-- equivalent to "add 1"

All of them will update the <objective> score of the player that ran them, but only if <objective> is a scoreboard objective of type trigger and has been enabled for that specific player with /scoreboard players enable <player> <objective>. Then you can have a system set up that runs every tick, displays the correct message to players with the correct score, and then clears the score.

Do note that /scoreboard players enable is only good for one use; after that you'll have to enable it again. It's common to run /scoreboard players enable @a myTriggerObj every tick, just to make sure all players can use the command any time they want.