When I send several commands in a row some don't get executed. For example I have a script which starts the roomba driving in a circle and plays the john cena theme song through its speakers but sometimes it will only play the music and not drive. I have noticed that in all the guides there are pauses after every command. Is there any documentation which describes when pauses are needed?
The pause between commands depends on how much time you need to wait for your particular commands to execute. For your example, you'll need to wait however much time it takes to drive in a circle before playing your theme song, then after that wait however long it takes to play the song before moving on to the next command. It might be better to take care of the pauses by using some kind of feedback about what the robot is doing instead of pre-programmed pause times. For example, use a loop to keep checking if the wheels are still turning or if the speaker is still playing.
The bottom line is that your code is being executed line-by-line with no attention being paid to whether the previous command has finished executing, so just remember to account for that when you design the program.