> If someone is behaving poorly, first of all, a CoC will not deter them.
I'm sorry, but that's just not true.
You're treating humanity as if it's divided into two distinct sections: Those Who Behave Well, and Those Who Behave Poorly.
In reality, different humans have different ranges of ways they prefer to act, and most are quite amenable to reasonable, clearly-stated codes of conduct for interaction in a particular space.
There is a small subset of people who are either deliberately antisocial for the sake of it (trolls/griefers/etc), and another subset that are genuinely just assholes who will, if given the leeway to do so, cause endless problems in a community.
But there are many, many more who would cause friction with others in such a community without a code of conduct not because they actively want to, but because their unstated assumptions about how people should interact clash with the unstated assumptions of other people there. Having the code of conduct lets everyone coming in in good faith align their expectations and avoid these unnecessary conflicts. They're like a Session 0 in a TTRPG in that sense.