Minecraft – How to spawn a command block with a command inside and have a certain condition chain ect

minecraft-commandsminecraft-java-edition

I'm making a map type thing where you have to get through challenges to win a prize. The problem is that I need to spawn a command block stack, I know who to spawn a command block with a command but I also need to change it so that the command block is set to chain and always active. This is the current command I'm using,

/setblock -585.601 68.00000 -471.700 command_block 0 replace {Command:"/playsound block.piston.extend voice @p"}

Best Answer

The things you are looking for are the blockstate (+8 if you want it to be conditional, as @Venya pointed out) and the chain command block, which goes by the name chain_command_block instead of a regular commandblock.
The other thing you're looking for is {auto:1}, the tag that makes the command always active.

So the complete command would be:

/setblock -585.601 68.0 -471.7 chain_command_block 8 replace {Command:"/playsound block.piston.extend voice @p",auto:1}

(I removed the unneccessary numbers from the coordinates as well)