To dream that you are in after-school detention, signifies guilt or shame about your actions. You need to learn to forgive yourself. Are you punishing yourself for something?
[1]1. Feelings of guilt or shame, likely from an adolescent activity.
2. Feelings of personal loss, loss of identity, dignity.
[2]