I am not a developer, so my knowledge is minimal on that stuff. I know a program called Alliance Auth which is doing exactly that what I was asking:
https://github.com/allianceauth/allianceauth
It handles the roles via a bot, but how that works I cannot say
So groups created in AllianceAuth also are being created on the discord server.