I mostly don't use Discord, but I'm intrigued how this system works. If the invite link is already posted on the project website and the readme of a Github repository, why would putting it in a Hacker News comment risk spammers?

First, because personally I think it's bad etiquette to post an invite link publicly on large, open-access forums like Hacker News.

Second, because while the biggest decompilation Discord servers have effective moderation team and processes, the vast majority are just a server for a project from one or a couple of persons with <100 members joined. Such small servers don't have round-the-clock moderation or customized settings.

Third, because I regularly see phishing crypto spam posted in the smaller servers. Spreading invite links publicly carelessly increases the odds that these scammers find them and spam them.

The part I don't understand is how posting the link on HN is different from posting it on Github. I'm wondering for example if Github has some sort of extra bot protection HN does not, or if there's some cultural difference I'm not aware of or seeing.

Discord servers are more like a hangout place than a public forum and public invite links are like putting a key under a mat. Just because the owners of a Discord server put it on their public webpage or GitHub repository doesn't mean it's cool to spread it around willy-nilly.

There are also practical concerns. An invite link that needs to be deleted (for example due to spam abuse) means that it will no longer work. Updating all the places where that old link appeared to the new one can be impractical or impossible.