#Getting "Unknown message" sometimes...

4 messages · Page 1 of 1 (latest)

tulip hinge
#

yo. Excluding command handling I have something like this:

client.on("interactionCreate", (interaction: Interaction) => {
    // if interaction is component I run execution method
    const loadingContent = loadingEmoji ? `<a:${loadingEmoji.name}:${loadingEmoji.id}>` : "...";
    const message = await interaction.reply({ content: loadingContent, ephemeral: true, fetchReply: true }) : null;
    reply(opts: ...) {
        delete opts .ephemeral;
        await message.edit(opts as ...);
    }
    // here are some actions. they are takes 2-30secs
    // and at the end I run reply function to send a message
    const error = await reply({ content: null, embeds: [...], files: [...] }).then(() => null).catch((e: Error) => e);
    // sometimes error is null, sometimes its not
});
#
DiscordAPIError[10008]: Unknown Message
    at handleErrors (D:\Project\node_modules\@discordjs\rest\dist\index.js:730:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (D:\Project\node_modules\@discordjs\rest\dist\index.js:1133:23)
    at async SequentialHandler.queueRequest (D:\Project\node_modules\@discordjs\rest\dist\index.js:963:14)
    at async _REST.request (D:\Project\node_modules\@discordjs\rest\dist\index.js:1278:22)
    at async GuildMessageManager.edit (D:\Project\node_modules\discord.js\src\managers\MessageManager.js:188:15)
    at async reply (D:\Project\dist\utils\buildComponentProps.js:62:13)
    at async MenuButtonsSelect.run (D:\Project\dist\commands\admin\menu\MenuButtonsSelect.js:144:30)
    at async MenuButtonsSelect.execute (D:\Project\dist\structures\bot\SelectMenuComponent.js:16:16)
    at async Object.run (D:\Project\dist\events\InteractionCreate.js:141:28) {
  requestBody: {
    files: [ [Object], [Object] ],
    json: {
      content: '',
      embeds: [Array],
      components: [Array],
      flags: 64,
      attachments: [Array],
      ...
    }
  },
  rawError: { message: 'Unknown Message', code: 10008 },
  code: 10008,
  status: 404,
  method: 'PATCH',
  url: 'https://discord.com/api/v10/channels/1264166929413836882/messages/1273000808085983305'
}```
The question that bothers me is: why does it sometimes work and sometimes not?
warm heronBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
tight birch
#

You can’t edit ephemeral messages that way. You need to use interaction.editReply(…)