odin-bot-v2 icon indicating copy to clipboard operation
odin-bot-v2 copied to clipboard

Abstract out isAdmin check to new utility in /utils

Open Asartea opened this issue 7 months ago • 1 comments

Complete the following REQUIRED checkboxes:

- [ ] The title of this issue follows the command name: brief description of request format, e.g. /help: add optional @user parameter

The following checkbox is OPTIONAL:

  • [x] I would like to be assigned this issue to work on it

1. Description of the Feature Request: We currently duplicate the code for checking if an user is an "admin" in a number of places using roughly this snippet[1]

      authorMember.roles.cache.forEach((value) => {
        if (config.roles.adminRolesName.includes(value.name)) {
          isAdmin = true;
        }
      });

this duplicates code, and also can be simplified to

const isAdmin = member.roles.cache.some((role) => roles.adminRolesName.includes(role.name))

It would be beneficial to abstract this functionality out to a new is-admin.js file in /utils

[1] Taken from points.js

2. Acceptance Criteria:

  • [ ] There is an utility function which checks if an member is an admin
  • [ ] All code that needs to check this uses the utility function

Asartea avatar Jul 13 '24 09:07 Asartea