How to test if a player is near coordinates in 1.13?

I can't seem to figure this out. I am trying to testfor if a player is near certain coordiantes, namely {-9, 100, 16}, and then to teleport them somewhere else.

In earlier versions it would be /testfor @a[x=-9,y=100,z=16,r=2] in a repeating command block going into a chain conditional command block that says /tp @p ~8 ~ ~, although it seems in 1.13 they have removed /testfor. I've seen that apparently I'm supposed to use /execute now in some way but I'm not sure how.


/execute already existed before and had most of the features it has now. But you don't even need that. Since you want to teleport relative to the command block, you can just use this:

/tp @a[x=-9,y=100,z=16,distance=..2] ~8 ~ ~

If you wanted to teleport the players 8 blocks from their location, you would use this:

execute as @a[x=-9,y=100,z=16,distance=..2] at @s run tp @s ~8 ~ ~