Skip to content

Replace role strings with a lookup table #2

@leepavelich

Description

@leepavelich

General Information

Summary

The codebase currently contains some hardcode strings like "admin" and "mentors" and it would be better to have those in a central lookup table.

Impact to Users

None, this is a code-quality issue.

Additional Information

Some examples of the hardcoded strings in the codebase as came up in a recent review:

if (!interaction.member.roles.cache.some((r) => r.name === "admin")) {

and
if (!interaction.member.roles.cache.some((r) => r.name === "mentors")) {

There may be others.

It would be better to store these in a lookup table in some roles.js file like

export const ROLES = {
  ADMIN: "admin",
  MENTORS: "mentors"
}

and then in the individual files you'd

import { ROLES } from './roles.js`

and replace the instances in the code like

"admin" -> ROLES.ADMIN
"mentors" -> ROLES.MENTORS

It might not be exactly like the above, but similar.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions