-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(MessageManager): extend API coverage #4869
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just another nit, would it be better to use async functions and await the promises, rather than .then(() => this)
?
Co-authored-by: Sugden <[email protected]>
Yeah I have no idea what's "better" here - I followed the convention which was already in place from the existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Edit Message and Crosspost Message endpoints the message is returned as a response on success, it could be be useful for developers to have the according methods to return the raw message data or the Message
itself. This would especially benefit those that don't have such messages cached and may need to access the data after calling the endpoint.
@izexi Thanks for the review! Before I merge those suggestions though there's a few things to discuss.
|
I don't really have a side on this too, I simply see it as making use of the data returned from the API which is would be a lot more useful than
I agree that would be a good idea to solve the inconsistency, but I feel like that somewhat defeats the purpose of attempting to separate the cache from the managers if the data would just be cached within the method itself. Although its not very intuitive if the developer wanted to cache the message that wasn't already cached after calling the method from the manager, they could call
Yes, that would be ideal but in other places objects are just vaguely typed as |
Co-authored-by: izexi <[email protected]> Co-authored-by: Advaith <[email protected]>
why isn't it imported from |
I think because that's not a dependency of discord.js yet? |
Will |
you can just use Channel#send though? |
Yeah, totally forgot about that :) 👍 |
This is to be the first of a few PRs I plan to make which adds additional methods to the Manager classes. Open to discussion and feedback (and additional testing please!) before I start submitting others.
This allows users to directly handle not only creating and fetching Messages from the Manager, but also editing, crossposting, reacting to, pinning and unpinning messages by ID, allowing management of uncached messages.
Key to this is that this furthers the separation of API and cache management that was sought to be achieved by introducing Managers in the first place. However most operations still relied on the existing of a Structure, in cache, for any API methods to be called. This does not replace those methods, but moves the API-handling code into the Manager and calls it from the Structure.
MessageManager seemed like the logical place to start with this given it already provided support for deleting by ID, and is one of the two most common areas a structure is likely to be uncached.
Like the existing delete method, these all return Promise rather than returning the updated cached structure, as they're designed to compatible with uncached Messages.
Status
Semantic versioning classification: