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

refactor/fix(DataStores): move instantiating of store related classes into their date stores #1869

Merged
merged 22 commits into from
Sep 3, 2017

Conversation

SpaceEEC
Copy link
Member

@SpaceEEC SpaceEEC commented Sep 1, 2017

Please describe the changes this PR makes and why it should be merged:

Data Store:

  • Defined client property in the DataStore's constructor before iterating the eventual passed iterable to avoid the client property being undefined when executing create.
  • Moved other instantiating of store related classes into their data stores (added optional cache parameter where needed)

(Guild)Channel Store:

  • Moved Channel instantiating to static Channel#create over instantiating in Channel Stores / any other files.
  • ChannelStore's iterable parameter in the constructor is actually a Client, renamed for clarity.
  • Added an optional iterable parameter.

GuildMember Store:

  • Fixed fetching of a single member without caching it (resolving of FetchMemberOptions#user)
  • Marked GuildMemberStore as public class so GuildMemberStore#fetch can be found in the docs.
  • GuildMemberStore#_fetchMany now rejects with the intended error message, rather then its key.
  • GuildMemberStore#_fetchMany now resolves when the limit of fetched members is reached or the full member count has been reached.

Regarding GuildMemberStore#_fetchMany:
How is fetching with a limit / query expected to work?
Fetching with a limit of 1000 fetches those 1000 but doesn't resolve the promies, which will time out and reject then.

The condition seems off here since members.size will (or should) never be < 1000.
See DiscordAPI docs: up to 1000 members per chunk (My bad, > and < are hard to read :^))

I am not sure how to fix this.

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

constructor(iterable, options = {}) {
super(iterable);
constructor(client, options = {}) {
super(client);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this remove the option of passing in an iterable? Not that I know a use case specifically where it would be needed, but all other stores can handle iterables being passed in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't possible previously, I just renamed the variable.
I'll add this either way, since all other stores are offering it.

SpaceEEC and others added 16 commits September 2, 2017 12:11
* such presence many good

* Update PresenceStore.js

* Update index.js

* Update ClientPresenceStore.js

* Update Presence.js

* Update ClientPresenceStore.js

* Update ClientUser.js

* Update Presence.js

* add timestamps and party

* Update Presence.js

* Update PresenceStore.js

* Update ClientPresenceStore.js

* Update ClientPresenceStore.js
…1875)

* fix: made options.type optional in ClientUser#setActivity

* some changes, smol fix

due to too many types being possible, it should just be defaulted to 0. this means streamers will have to set the type manually, though.
also mistake with activity.name check
Since the return value of Collection#exists is basically just a boolean of Collection#find's result, the same documentation and arguments can and should be applied.
… into the relevant create methods and fixed FetchMemberOptions
@iCrawl iCrawl merged commit c4b5736 into discordjs:master Sep 3, 2017
@SpaceEEC SpaceEEC deleted the DataStores branch September 3, 2017 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants