How can I prevent phantoms spawning with commands in 1.15+?

I do not like phantoms. How can I prevent them from spawning?


Solution 1:

Use /gamerule doInsomnia false, which turns off phantom spawning at nighttime. Full list of commands