Can I add player rotation to this command?

I'm trying to implement player rotation in order to work with the teleport argument, as such:

/tp [target player] <x> <y> <z> [<y-rot> <x-rot>]

But in this command instead:

/execute positioned ~ ~-1 ~ if entity @e[distance=..5] run tp @p ~12 ~15 ~

Is it possible?


Solution 1:

The autocomplete of /execute is a bit messed up. For example it only shows as when you enter /execute rotated. But you can still do this:

/execute rotated 12.3 ~-45.6 run <command>

This is also documented here (archive).