Make ClientEvents, CollectorFilter and Message types generic. #5447
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please describe the changes this PR makes and why it should be merged:
I've added some generic type parameters for the following types for the respective reasons stated below.
->
CollectorFilter
- I feel that this type would benefit from being able to define exactly what parameters will be passed in to the function. Not only does this leave less room for mistakes but it also makes it so users don't have to work with the typeany
as much when they're using TypeScript.->
ClientEvents
- This type has been given a generic parameter which dictates which events will emit partial data. This is useful as redundant checking for partial data won't be required if the user has not enabled the respective partial in theClientOptions
.->
Message
- The generic parameter for this type describes whether or not the message was sent in a guild. When you're working with messages you often have to check whether or notMessage#guild
is null even when you're pretty certain it isn't, insertingMessage#guild as Guild
everywhere is also much less elegant. This parameter can also be used to add more type information to the return types of some functions, such asMessage#reply
which will always return aMessage
which was sent in a guild if the original message was sent in a guild.Status and versioning classification: