Some people will always be shitty, some people will want to play your game, and some number of people will meet both those criteria. The only way to fix it is after the fact, but there’s no way to avoid it.
As to the “how and to what degree” depends on the game and the type of person it attracts. The second something is competitive, toxicity is inevitable because many people take losing personally.