Note that there's an error in the assumptions behind the discord regex, discord invites do not necessarily have "invite" in the url, and may use the domain discord.gg instead. For instance the yarn repo[0] uses the url "https://discord.gg/yarnpkg" which was missed by your search. Another worthwhile mention is the Svelte repo[1], which uses discord, but instead of linking directly to their discord invite, links to "https://svelte.dev/chat" which then redirects to their discord invite.
Looking for the "discord.gg/invitecode" pattern[2] gives 27k results, safe to say discord is severely under-represented in your statistic.
* 28k for Discord[0]
* 1.4k for Matrix[1]
[0] https://sourcegraph.com/search?q=context:global+%28https://d...
[1] https://sourcegraph.com/search?q=context:global+https://matr...