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

Replace role strings with a lookup table #2

Open
leepavelich opened this issue Nov 10, 2022 · 0 comments
Open

Replace role strings with a lookup table #2

leepavelich opened this issue Nov 10, 2022 · 0 comments
Assignees
Labels
Code quality Improvement to code quality good first issue Good for newcomers

Comments

@leepavelich
Copy link

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.

@leepavelich leepavelich added good first issue Good for newcomers Code quality Improvement to code quality labels Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code quality Improvement to code quality good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants