That is indeed how Matrix works already. And Discord is also doable with https://gitlab.com/An0/SimpleDiscordCrypt
However server side... :) Looked probably twice to hosting Matrix server and Java part was fat no no. And Discord one-click "servers" ? :)
Edit:
Ok, can't find any Java in Matrix servers context... Must be I messed it with Signal server.