MaksiRose / paw-and-paper

Multipurpose bot for roleplayers, alterhumans and furries, featuring a community-centered RPG.
https://discord.com/api/oauth2/authorize?client_id=862718885564252212&permissions=518385954112&scope=bot
GNU General Public License v3.0
3 stars 3 forks source link

Deleting the somersaulting-message fails #708

Closed MaksiRose closed 1 year ago

MaksiRose commented 1 year ago

Created by: FlockInATrenchcoat#5081 (809548732969386024)

DiscordAPIError[10008]: Unknown Message
    at SequentialHandler.runRequest (/home/discord-bots/paw-and-paper/node_modules/@discordjs/rest/dist/index.js:667:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (/home/discord-bots/paw-and-paper/node_modules/@discordjs/rest/dist/index.js:464:14)
    at async REST.request (/home/discord-bots/paw-and-paper/node_modules/@discordjs/rest/dist/index.js:910:22)
    at async InteractionWebhook.deleteMessage (/home/discord-bots/paw-and-paper/node_modules/discord.js/src/structures/Webhook.js:385:5)
    at async ButtonInteraction.deleteReply (/home/discord-bots/paw-and-paper/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:175:5)
    at async Timeout._onTimeout (/home/discord-bots/paw-and-paper/dist/utils/checkValidity.js:73:13)
{
    "id": "1060232502352035931",
    "application_id": "862718885564252212",
    "type": 3,
    "data": {
        "component_type": 2,
        "custom_id": "explore_new_@22371llgzb935ak8"
    },
    "guild_id": "854865589217787924",
    "channel_id": "1019037981383852032",
    "user_id": "809548732969386024",
    "message": {
        "id": "1060232034028617888",
        "timestamp": 1672849415071,
        "edited_timestamp": 1672849435298,
        "type": 0
    },
    "timestamp": 1672849526728,
    "app_permission": "1073577717329",
    "locale": "en-US",
    "guild_locale": "en-US"
}

Additional conversation:

FULL CONVERSATION REGARDING THIS TICKET
MaksiRose commented 1 year ago

This is the code for this. The problem is first of all that the reply isn't caught so the ID is not the ID of the message. This happened because it's assumed that this is a followUp. Either followUps aren't guaranteed to be full messages, or this isn't always a followUp. https://github.com/MaksiRose/paw-and-paper/blob/e3df0b80c35742c7ac3fce21c822d1de08d7c4a4/src/utils/checkValidity.ts#L83-L99

This could be solved in several ways, either by deleting '@original' in case the id is from an InteractionResponse (although this requires making sure that followUps aren't InteractionResponses ever), or fetching the reply. There should also be backup code, one that tries to fetch and delete the message normally, and one for that that just silently returns in case the message doesn't exist.

MaksiRose commented 1 year ago

Update - This shouldn't always be a followUp but always a reply. So it should try to do '@/original'