nationalcollegiateesports / discord-bot

MIT License
2 stars 0 forks source link

Role Menu #4

Open themaxdavitt opened 3 years ago

Nick-Sol commented 3 years ago

Right now for our role menu, we tie role names to the custom emoji names so when a reaction is clicked we can pull its name and then look up the role and add or remove it to the user. Outside of that we just have a long switch statement. I was thinking for roles whose names are different from the emoji name could we do a key:value pair to look up what that reaction is mapped to role wise? Might be a better way to do this but what I have off the top of my head

themaxdavitt commented 3 years ago

Essentially (our code isn't the cleanest) we have an object whose keys are either unicode emoji characters or Discord emoji IDs and whose values are role IDs. We used to map them by emoji/role names instead of IDs but rewrote it because users don't expect changing emoji and role names to break anything (it's happened before) + I was refactoring to support using unicode emoji anyways. This was shortly after I realized that my beloved Google Sheets configuration method was never going to be used and so using strange-looking ID numbers wouldn't hurt anyone - that's a story for another time though.

Nick-Sol commented 3 years ago

That's a good point, since I told them not to change react names I got lucky and haven't had issues. Since we are scaling that's a good point of tieing to ID's.