This commit refactors a lot of packages.
It refactors the handler package, removing the Synchronous field and
replacing it the AddSyncHandler API, which allows each handler to
control whether or not it should be ran synchronously independent of
other handlers. This is useful for libraries that need to guarantee the
incoming order of events.
It also refactors the store interfaces to accept more interfaces. This
is to make the API more consistent as well as reducing potential useless
copies. The public-facing state API should still be the same, so this
change will mostly concern users with their own store implementations.
Several miscellaneous functions (such as a few in package gateway) were
modified to be more suitable to other packages, but those functions
should rarely ever be used, anyway.
Several tests are also fixed within this commit, namely fixing state's
intents bug.
This commit makes it so that all sharded state.State instances will have
its own cabinet store on construction. This ensures that when a State is
reconnected, a Ready event won't wipe the cabinet for all other states.
This commit also fixes a bug with the Shard() and FromGuildID() getters.
* Store,State: Add update param to all store.XXXStore.XXXSet methods
* State: add paginating Messages
* Store: Fix test error
* store: merge shouldPrependMessage and shouldAppendMessage into single messageInsertPosition
This commit refactors the Store interface in State into smaller
interfaces in package store. These interfaces are combined into one
structure called a "Cabinet". The default implementation of those
interfaces have been rewritten in package defaultstore, while the old
no-op implementation stays with the store package.
This commit also omitted several state handlers for user events, as it
is unclear what they are actually structured like.
This addresses discord/discord-api-docs#1440.
State documentation has been added, which documents the store and
handlers as well.
Bug fixes include:
- PreHandler being called after the state handler; it is now called
before as documented.
- Minor behavior changes regarding Guild Create events. Refer to State's
documentation.
* State: fix State.Message not working when the message's channel is not found in the Store
* State: fix State.Message not working when the message's channel is not found in the Store