DiscordSRV

DiscordSRV

86.8k Downloads

Discord Role -> MC Group Synchronization

Scarsz opened this issue · 8 comments

commented

Not sure how this is going to be implemented. With my limited amount of brainstorming, the only plausible way I can see this working is if you have pairs of Discord roles and their MC group equivalent; these pairs would have an accompanying "promote" and "demote" command for the actions needed.

Example:

"pairs": [{
    "roleId": "11111111111111111111",
    "groupName": "vip+",
    "promoteCommand": "...",
    "demoteCommand": "..."
}, {
    "roleId": "22222222222222222222",
    "groupName": "vip++",
    "promoteCommand": "...",
    "demoteCommand": "..."
}, {
    "roleId": "33333333333333333333",
    "groupName": "vip+++",
    "promoteCommand": "...",
    "demoteCommand": "..."
}]

I don't really know how well this would work with all the different permissions plugins though.

commented

I think that would work well however to make it more clear in the config it might be smart to do something like this:

pairs:
  1:
    role-id: “1111111111111111”
    group-name: “vip”
    promote-command: “cmd”
    demote-command: “cmd”

This is so that it is much easier to configure as it can be quite difficult for most mc kids..
they can then just copy and paste and change everything. The firs key ‘1’ in this case could be anything random or you could use it for something (priorities?)

commented

My example was just that: an example. It was just to demonstrate the structure. I wouldn't be putting JSON in a YAML config file.

commented

I'm interested in this feature... is it going to be added eventually? :D

commented

Its just my implementation that its possible and quite easy
https://gist.github.com/LosTigeros/8d4e71583046823ca1b6c30bd77d046b

commented

So to further develop on this idea I've come up with a config (similar to the ones mentioned above but a bit more in depth on what they do and how the whole system works)

Config:

#SyncUpdateInterval: <Integer> (How often the bot checks for Role Changes in seconds (this only apply's on my 2nd way of how this could work))
SyncUpdateInterval: 15

#PermissionPlugin: <Name> (Tells the plugin what permission plugin you are using (doesn't have to be like this because i heard Vault merges them all and you can control roles with Vault? correct me if i'm wrong))
#Available options
# LuckPerms
# Groupmanager
# PEX
PermissionPlugin: LuckPerms 

# roles: (this is mandatory)
#    level1: (this can be called anything (user preference)
#       discord: '<roleid>' (role id required in case of any mishaps in similar names)
#       minecraft: '<Rolename>' (role name in minecraft)
#       set: '<Main or sub>' (determines if this group is a Main group, or a sub group)

roles:
    level1:
        discord: '0923478023489237'
        minecraft: 'Level1'
        set: 'main'
   
    builder:
        discord: '203894720394787'
        minecraft: 'Builder'
        set: 'sub'

Method 1

(I have no coding experience so please don't have a go at me if i get something wrong)

This method uses the GuildMemberRoleAddEvent in Discord JDA and the process of what executes is....

Method 1 Process

  1. The plugin waits for a role user update event.
  2. When it detects an update It checks what Role was added and checks to see if that role is in the config.
    1. If its not in the config it stops here and doesn’t continue.
  3. It then proceeds to get the users ID that received the role update.
  4. With their ID it gets their linked MC username from the config "linkedaccounts.json"
    1. If not linked to an account it stops here and doesn’t continue.
  5. And finally puts in a command based on the config (including Role name, Main/Sub group and their minecraft username)

Method 2

(I've not looked into this method as much as Method 1, this one was made up on the spot)

This method (based on the "SyncUpdateInterval" option on the config) mass checks everyone's roles on the discord and mass updates all of them, personally i think this one is Super unoptimised and will lag the heck out of a server, but im just putting out an idea here. So the way i think this one would work is....

Method 2 Process

When it gets activated (based on the config) it.

  1. Checks what role ID's there are on the config and Stores them
  2. Check what Users have said roles on the discord.
  3. Make a list of user ID's (that have said roles) and process them through the "linkedaccounts.json" and retrieves MC username's
  4. Finally goes through that list 1 by 1 and executes commands based on the config. (what roles, Sub/Main, and their MC name)

Issues

The only issue i can see with this is the conflict between MC-->Discord and Discord-->MC. my suggestion to that is to have an option to have one or the other (disable one or another).

commented

Would love this feature too, any chance of this happening?

commented

If you don't want to wait then you can make something based on my implementation posted above. It syncs discord groups to the ones made in pex

commented

This was implemented in PR #640 -- dev builds available @ https://snapshot.discordsrv.com
if you have problems Discord support @ https://discordsrv.com/discord