If it’s involuntary on the kid’s part, it may actually be illegal. I don’t think the laws explicitly exclude after-school “detention”.
You have the right to remain silent. Use it!
You have the right to obey your teacher during class, and never come to detention again.