That is why it is necessary for you to mess around every now and then. A little.
Getting a detention is not the end of the world. If people look at you like one of those perfect students, you are not going to have many friends. In fact, you’ll probably get made fun of for being a dork. It is fine if you put effort into your classes and everything, but you really need to mess around once in awhile.