refactor: Move member role-related functions to a special store (#2242)

* Ignore this I need a patch branch for Git

* Move all member role related stuff to a new DataStore
GuildMemberRoleStore is a new store that holds all member role related stuffs
Because its consistent!

* Minorest doc fix ever
To whoever did this object, they forgot a `{`

* Fix the spacing in the docs

* Resue the stores resolve rather than copy paste
Cause I'm dum and it overwrite resolve to the guild role stores resolve soo

* Fix some requests
- Removed the bs private functions
- Set the roles in the constructor

But, I need feedback. There is no way, that I saw, to make a member have roles whenever GuildMmber#_patch is called,
due to the roles being null on the guild. So the only way might be the for loop and getter.

* Fix an issue that I caused in #add
I was testing some other things, and changed that to test. Forgot to change it back

* Actually make the store generate just once when the member is created by first initializing the roles in the guild
Also replaces GuildMember#_roles with GuildMemberRoleStore#_roles
Tested all functions to make sure the expected result happens.

* I missed this from moving remove from GuildMember to GuildMemberRoleStore

* Fix RoleStore#create docs
For real this time

* Do all the requested changes
- Rename all `somethingRole` to `something` (hoistRole => hoist)
- Refactor add and remove to be cleaner and re-use set

* Fix a bug where the store would loose some roles due to null roles that can throw an error in the for loop after they've been deleted

* Remove the `role.id || role` part of the add and remove functions as Appel suggested

* Replace roles.resolve with roles.resolveID for GuildMemberRoleStore#remove

* Don't use Array.isArray in checks
Use instanceof instead

* Woops, I forgot to change this
Renamed colorRole to color

* The docs have dots, so we place the dots back
This commit is contained in:
Frangu Vlad
2018-01-24 09:12:58 +02:00
committed by SpaceEEC
parent 5352e28700
commit 00172e6c7d
5 changed files with 189 additions and 181 deletions

View File

@@ -29,6 +29,7 @@ module.exports = {
GuildChannelStore: require('./stores/GuildChannelStore'),
GuildEmojiStore: require('./stores/GuildEmojiStore'),
GuildMemberStore: require('./stores/GuildMemberStore'),
GuildMemberRoleStore: require('./stores/GuildMemberRoleStore'),
GuildStore: require('./stores/GuildStore'),
ReactionUserStore: require('./stores/ReactionUserStore'),
MessageStore: require('./stores/MessageStore'),