mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
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:
@@ -34,7 +34,7 @@ class RoleStore extends DataStore {
|
||||
* name: 'Super Cool People',
|
||||
* color: 'BLUE'
|
||||
* },
|
||||
* reason: 'we needed a role for Super Cool People',
|
||||
* 'we needed a role for Super Cool People',
|
||||
* })
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
@@ -61,22 +61,22 @@ class RoleStore extends DataStore {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a RoleResolvable to a Role object.
|
||||
* @method resolve
|
||||
* @memberof RoleStore
|
||||
* @instance
|
||||
* @param {RoleResolvable} role The role resolvable to resolve
|
||||
* @returns {?Role}
|
||||
*/
|
||||
* Resolves a RoleResolvable to a Role object.
|
||||
* @method resolve
|
||||
* @memberof RoleStore
|
||||
* @instance
|
||||
* @param {RoleResolvable} role The role resolvable to resolve
|
||||
* @returns {?Role}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a RoleResolvable to a role ID string.
|
||||
* @method resolveID
|
||||
* @memberof RoleStore
|
||||
* @instance
|
||||
* @param {RoleResolvable} role The role resolvable to resolve
|
||||
* @returns {?Snowflake}
|
||||
*/
|
||||
* Resolves a RoleResolvable to a role ID string.
|
||||
* @method resolveID
|
||||
* @memberof RoleStore
|
||||
* @instance
|
||||
* @param {RoleResolvable} role The role resolvable to resolve
|
||||
* @returns {?Snowflake}
|
||||
*/
|
||||
}
|
||||
|
||||
module.exports = RoleStore;
|
||||
|
||||
Reference in New Issue
Block a user