Note that this is Moses speaking rather than God, but if you read it in context, you will see that Moses and God are speaking in turns, laying out the covenant that God has already given to Moses. Obviously, if Moses contradicted God's covenant at some point, it seems likely that something bad would have happened. Therefore, Moses' statements in the Book of Leviticus are presumably an accurate testimony of God's instructions to him on the mountain.
"Then Moses said to Aaron and his sons Eleazar and Ithamar, "Do not let your hair become unkempt, and do not tear your clothes, or you will die and the LORD will be angry with the whole community."--Leviticus 10:6