How do I teleport a player to a random position?

Solution 1:

As far as I know, there is no way to directly generate a random number using commands, and there definitely isn't any way to then plug that random number into another command block.

However, the spreadplayers command will do what you're after here. spreadplayers is designed to place groups of, or individual players, in random spots around the map.

The syntax is as follows for Java Edition: /spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <player>. <x> <z> specifies the center of the map, <spreadDistance> specifies the minimum distance between the targets, <maxRange> specifies the maximum horizontal distance to place players from the center, <respectTeams> specifies whether or not teams should be kept together, and <player> specifies your targets.

In the particular case of sending a single @p to some location between x,z (-100,-100) and (100,100), the command would look like so:

/spreadplayers 0 0 0 100 false @p