There isn't one.
I recently spent a few weeks looking for exaclty that and I had no look.
I've looked into XMPP, Matrix and other FOSS self hosted options. There isn't anything out there offering the exact features as discord.
Disclaimer: I don't use discord and never will. But I do game frequently with a few close friends. I have bothered them so much asking them to try a few options.
Basically their requirements were:
- support for desktop (linux and windows)
- support for mobile (android)
- voice channels where you can see who's online before joining
- means to bundle several "channels" in a group (discord spaces)
My friends complained a lot about XMPP android apps, they mentioned the options available felt unfinished and looked ugly. I understand that's just an opinion but that is important for some people. Edit: spelling
The closest thing we've found is matrix, which is what we are using. But there really is only one client that works on the desktop/webapp, which is element. For android the only one available is schildichat next (spelling probably wrong). Matrix is also very tricky because not all server implementations support audio/video. The ability of seeing who's online before joining isn't available yet.
Matrix still lacks in many other things discord has to offer. I haven't been able to get stickers working, for instance. Not a dealbreaker for my friends but others may think differently.
I am not advocating for Matrix. It is very cumbersome because it depends on having the exact server and client that works. But it is what we are using.