Reimnop / Discord4Fabric

A beautiful Discord bot client for Fabric
MIT License
37 stars 20 forks source link

[Feature Request] Add LuckPerms actions and constraints to Custom Events #52

Open elhertz opened 2 years ago

elhertz commented 2 years ago

Hey I'm using this to link my luckperms parents/groups to my discord roles: In this case D4F has no way of knowing if an user is already in a LP's parent so the command will run every time an user joins the server. It's not bad but it would be nice to have a way to check if the user already has the parent added before running the command.

{
  "player_join": {
    "requires": [
      "linked_account_has_role('role')"
    ],
    "actions": [
      {
        "id": "run_command",
        "value": "lp user %player:name_unformatted% parent add parentname"
      }
    ]
  }
}

Example constraint suggestions: user_has_luckperms_parent('parentname') user_has_luckperms_permission('permission.node')

Example action suggestions: luckperms_set_parent luckperms_add_parent luckperms_remove_parent luckperms_set_parent

{
  "id": "luckperms_add_parent",
  "value": {
    "user": "%player:name_unformatted%",
    "parent": "server_booster"
  }
}

Example usage when you want to link the "newbie" discord role to the "newbie" luckperms role but you want to exclude users with the "admin" parent:

{
  "player_join": {
    "requires": [
      "linked_account_has_role('Newbie')",
      "!user_has_luckperms_parent('admin')"
    ],
    "actions": [
      {
        "id": "luckperms_add_parent",
        "value": {
          "user": "%player:name_unformatted%",
          "parent": "newbie"
        }
      }
    ]
  }
}