Getting "Unknown interaction" error even with interaction.deferReply()

Hey folks, I am getting a strange error with this code:

class StandingsInteraction {
    public async interaction(interaction: TypedCommands['standings']) {
        // interaction is ChatInputCommandInteraction
        await interaction.deferReply();

        const { data, expired } = await standingsCache.getData();

        if (!expired) {
            return await interaction.editReply({
                content: data // data is a string here
            });
        }

        const res = await interaction.editReply({
            files: [{
                attachment: data, // data is a Buffer here
                name: 'la-liga-standings.png'
            }]
        });

        standingsCache.revalidate(res);
    }
}

The problem is that I am randomly getting this error, and I can't figure out why since I am deferring the reply:

DiscordAPIError[10062]: Unknown interaction
    at handleErrors (/home/node_modules/@discordjs/rest/dist/index.js:687:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async BurstHandler.runRequest (/home/node_modules/@discordjs/rest/dist/index.js:786:23)
    at async _REST.request (/home/node_modules/@discordjs/rest/dist/index.js:1218:22)
    at async ChatInputCommandInteraction.deferReply (/home/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:69:5)
    at async StandingsInteraction.interaction (file:///home/apps/discord/out/commands/standings.js:5:5)
    at async interactionController (file:///home/apps/discord/out/commands/_controller.js:31:7)
    at async Client.<anonymous> (file:///home/apps/discord/out/index.js:13:5) {
  requestBody: { files: undefined, json: { type: 5, data: [Object] } },
  rawError: { message: 'Unknown interaction', code: 10062 },
  code: 10062,
  status: 404,
  method: 'POST',
  url: 'https://discord.com/api/v10/interactions/.../callback'
}


I searched online for the problem but without much success.
Was this page helpful?