forked from sandarutharuneth/ivongiveaways
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Code qualityImprovement to code qualityImprovement to code qualitygood first issueGood for newcomersGood for newcomers
Description
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:
discord-shift-swap/slash/edit.js
Line 35 in 40483d5
| if (!interaction.member.roles.cache.some((r) => r.name === "admin")) { |
and
discord-shift-swap/slash/trade.js
Line 20 in 40483d5
| 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.MENTORSIt might not be exactly like the above, but similar.
Metadata
Metadata
Assignees
Labels
Code qualityImprovement to code qualityImprovement to code qualitygood first issueGood for newcomersGood for newcomers