Skip to content

Message with SUPPRESS_EMBEDS can still have embeds. #4442

@wtgtybhertgeghgtwtg

Description

@wtgtybhertgeghgtwtg

Description

I have been working on a bot that can suppress embeds for messages with specific URL's. An intermittent issue that I have been running into has been a message with a suppressed embed showing that embed anyway. This seems to be happening when the call to suppress embeds resolves before the server can discover what it would embed.

Steps to Reproduce

Create a bot that will immediately suppress the embeds of a message. With discord.js, it'd be something like

import {Client, Intents, Message} from 'discord.js';

const client = new Client({
  intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});

client
  .on('messageCreate', (message) => {
    console.log({messageId: message.id});
    message.suppressEmbeds().catch(() => {});
  })
  .on('messageUpdate', (oldMessage, newMessage) => {
    console.log(
      {
        messageId: oldMessage.id,
        newEmbedsCount: newMessage.embeds.length,
        newFlags: newMessage.flags,
        oldEmbedsCount: oldMessage.embeds.length,
        oldFlags: oldMessage.flags,
      });
  })
  .once('ready', () => {
    console.log('The client is ready.');
  });

client.login(YOUR_TOKEN_HERE).catch(error => {
  console.log('The client failed to log in.');
});

In a channel the bot is active, enter some URL (ideally a page from a site that has a degree of latency, or using a URL shortener). Several URL's may have to be used, since Discord seems to have a cache mechanism for embeds.

Expected Behavior

The message should not have any embeds at any point after the call to suppress embeds resolves.

Current Behavior

The message may have an embed, even with the SUPPRESS_EMBEDS flag.

Screenshots/Videos

No response

Client and System Information

Chrome 98, discord.js 13.6.0, Linux Mint 20.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsyncedSynced to internal tracker

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions