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

fix(Message): flags not being parsed on some edits #5886

Merged
merged 2 commits into from Jun 23, 2021

Conversation

monbrey
Copy link
Member

@monbrey monbrey commented Jun 20, 2021

One of those rabbit hole bugs that made me change a few things.

To start with, Message#suppressEmbeds was broken. This is because:

  1. Internally that method calls Message#edit({ flags: 4 }).
  2. That method then calls MessageManager#edit(this.id, options)
  3. MessageManager#edit constructs an APIMessage with this as the target.
  4. APIMessage#resolveData only resolves flags if the APIMessage#target is a Message or Interaction.
    https://github.com/discordjs/discord.js/blob/master/src/structures/APIMessage.js#L159-L164

So, I decided that:

  1. Message#edit should pass this rather than this.id.
  2. MessageManager#edit should pass the whole message to APIMessage#target if provided with one.
  3. APIMessage should support MessageManager as a target also, for when making cacheless edits by ID.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

@@ -120,16 +120,19 @@ class MessageManager extends BaseManager {
* @returns {Promise<Message>}
*/
async edit(message, options) {
message = this.resolveID(message);
Copy link
Member

Choose a reason for hiding this comment

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

No more mutation, hooray 🧹

src/managers/MessageManager.js Outdated Show resolved Hide resolved
@iCrawl iCrawl merged commit 2d7c12b into discordjs:master Jun 23, 2021
@monbrey monbrey deleted the fix-message-manager branch June 24, 2021 21:35
@iCrawl iCrawl added this to the Version 13 milestone Jun 27, 2021
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.

Message.suppressEmbeds() returns DiscordAPIError instead of suppressing embed
5 participants