Preventing a macOS from going to sleep is one of those things that I don't need to do often enough as to build finger memory.

You can find sleep options in System Preferences, or you can set them using terminal.

$ cd /Applications/Utilities && sudo pmset sleep 0

If after fiddling around with System Preferences you are still having issues or you just prefer to use the CLI, you might want to try pmset.

pmset manages power management settings such as idle sleep timing, wake on administrative access, automatic restart on power loss, etc.

The following command will prevent the computer from going to sleep no matter how loing the machine is idle. You open a terminal window, and type the command. When you are done, simply CRL + C to exit.

$ pmset noidle
Preventing idle sleep (^C to exit)...

An alternative is to use caffeinate to run your own script, or to call it from your own script.

caffeinate creates assertions to alter system sleep behavior. If no assertion flags are specified, caffeinate creates an assertion to prevent idle sleep. If a utility is specified, caffeinate creates the assertions on the utility's behalf, and those assertions will persist for the duration of the utility's execution. Otherwise, caffeinate creates the assertions directly, and those assertions will persist until caffeinate exits.