Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upfeat(MessageManager): extend API coverage #4869
Conversation
just another nit, would it be better to use async functions and await the promises, rather than |
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 |
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 |
@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? |
clone._patch(d); | ||
return clone; | ||
}); | ||
return this.channel.messages.edit(this.id, content, options).then(() => this); |
vladfrangu
Oct 17, 2020
Member
The then
will cause a different output than before (patched clone vs now the same message without the edits
The then
will cause a different output than before (patched clone vs now the same message without the edits
monbrey
Oct 17, 2020
Author
Contributor
Yeah I gotcha now, will resolve this.
Yeah I gotcha now, will resolve this.
@@ -2184,6 +2207,95 @@ declare module 'discord.js' { | |||
|
|||
type APIMessageContentResolvable = string | number | boolean | bigint | symbol | readonly StringResolvable[]; | |||
|
|||
interface APIRawMessage { |
vladfrangu
Oct 17, 2020
Member
This interface is incomplete.. why don't we use discord-api-types
? I also don't remember the discussion for that
This interface is incomplete.. why don't we use discord-api-types
? I also don't remember the discussion for that
monbrey
Oct 17, 2020
Author
Contributor
I'm happy to use it, just not sure if this PR should be covering that. I copied the interface from the PR izeki referenced in his comments.
I'm happy to use it, just not sure if this PR should be covering that. I copied the interface from the PR izeki referenced in his comments.
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: