Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added change_roles automod action #284

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Added change_roles automod action #284

wants to merge 19 commits into from

Conversation

metal0
Copy link
Contributor

@metal0 metal0 commented Sep 8, 2021

plugins:
  automod:
    config:
      rules:
        testrule:
          triggers:
            - match_words:
                words: ["testrl"]
          actions:
            change_roles:
              add: ["885116460261863425"]
              remove: ["885116523067375666"]

Fixes

This PR is meant to fix the issue of having both add_roles and remove_roles not functioning when used together.
I tried to fix the core issue at hand with the individual methods (i.e. the Member object's roles not being up-to-date by the time it reaches the 2nd action) but there was no super easy fix for this that I could find.

Regardless it would've still been 2 dapi requests, with this PR all role changes originating from a rule are now guaranteed to only be a single dapi request (since you can no longer use both add_roles and remove_roles)

@almeidx wtb review

backend/src/plugins/Automod/actions/addRoles.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/actions/changeRoles.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/actions/changeRoles.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/actions/changeRoles.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/actions/changeRoles.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/actions/removeRoles.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/AutomodPlugin.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/AutomodPlugin.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/AutomodPlugin.ts Outdated Show resolved Hide resolved
backend/src/plugins/Automod/AutomodPlugin.ts Outdated Show resolved Hide resolved
metal and others added 16 commits September 8, 2021 14:14
@metal0
Copy link
Contributor Author

metal0 commented Sep 23, 2021

WARNING!!!!

This will cause misconfiguration errors on bot startup (due to the config checks I added) if anyone has both add_roles AND remove_roles on their server's config!!

Flokie tried to add this to his instance and was instantly met with the misconfiguration error, do NOT merge this without some sort of migration

WARNING!!!!

@metal0 metal0 closed this by deleting the head repository Feb 10, 2023
@metal0 metal0 reopened this Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants