Making a book with clickable buttons to move to Spawn, The Nether and The End [duplicate]

I have been working on getting a server up and running and I don't want to use anything but NBT data edits and command blocks no plugins, but any who I'm very tired and cant seem to wrap my head around this so I'm asking someone else, I have this snippet of code:

/tellraw @p ["",{"text":"Yes","color":"green","bold":"true","clickEvent":{"action":"run_command","value":"/tellraw @p {\"text\":\"Confirmed!\",\"color\":\"green\"}"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Confirm","color":"green"}]}}},{"text":"/","color":"dark_gray","bold":"false"},{"text":"No","color":"red","bold":"true","clickEvent":{"action":"run_command","value":"/tellraw @p {\"text\":\"Cancelled\",\"color\":\"red\"}"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Cancel","color":"red"}]}}}]

I believe I found that somewhere on Arqade and I need a book through the /give. I believe the when opened will present you with 3 options 1 for the world spawn 1 for nether(or just another set of /tp cords that I can change the xyz to what I need as I do not think you can travel between dimensions via commands) and 1 for the end if you could help that would be awesome


Solution 1:

You can either do 2 things to get the player out of other dimensions with commands. Kill the player and turn on the keep inventory game-rule then teleport them to spawn or teleport the player to a end portal then teleport them to spawn. Here is the end portal method but you will have to press ESC every time you teleport to spawn from the nether or the end. You will have to make 2 end portals some where in the nether and the end for this to work.

/scoreboard objective add tp trigger
/scoreboard objective add tp1 dummy
/trigger tp set 1 (use this cmd to teleport to spawn)

/scoreboard players enable @a tp
/scoreboard players set @a[score_tp_min=1,score_tp=1] tp1 0
/scoreboard players reset @a[score_tp_min=1] tp
/scoreboard players set @a[score_tp1_min=0,score_tp1=0] tp1 1 {Dimension:1}
/scoreboard players set @a[score_tp1_min=0,score_tp1=0] tp1 -1 {Dimension:-1}
/tp @a[score_tp1_min=-1,score_tp1=-1] x y z (nether end-portal)
/tp @a[score_tp1_min=1,score_tp1=1] x y z (end end-portal)
/scoreboard players set @a[score_tp1_min=-1,score_tp1=-1] tp1 2
/scoreboard players set @a[score_tp1_min=1,score_tp1=1] tp1 2
/tp @a[score_tp1_min=0,score_tp1=0] x y z (spawn)
/scoreboard players reset @a[score_tp1_min=0,score_tp1=0] tp1
/scoreboard players set @a[score_tp1_min=2,score_tp1=2] tp1 0