DawnbrandBots/emcee-tournament-bot

Handle participant dropping before deck submission is approved

Opened this issue · 0 comments

When a participant drops (or leaves the server) before a deck submission is approved, once a host clicks either accept button, the error flow is not properly handled.

Example logs at error level:

EntityNotFoundError: Could not find any entity of type "ManualDeckSubmission" matching: {
    "where": {
        "discordId": "REDACTED",
        "tournamentId": REDACTED
    }
}
    at <anonymous> (/app/node_modules/typeorm/entity-manager/src/entity-manager/EntityManager.ts:1252:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at AcceptButtonHandler.click (/src/slash/deck.ts:140:16)
    at Client.interactionCreate (/src/events/interaction.ts:112:4)
EntityNotFoundError: Could not find any entity of type "ManualDeckSubmission" matching: {
    "where": {
        "discordId": "REDACTED",
        "tournamentId": REDACTED
    }
}
    at <anonymous> (/app/node_modules/typeorm/entity-manager/src/entity-manager/EntityManager.ts:1252:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at approveDeck (/src/slash/deck.ts:169:15)
    at QuickAcceptButtonHandler.click (/src/slash/deck.ts:209:3)
    at Client.interactionCreate (/src/events/interaction.ts:112:4)

https://github.com/DawnbrandBots/emcee-tournament-bot/blob/master/src/slash/deck.ts#L140
https://github.com/DawnbrandBots/emcee-tournament-bot/blob/master/src/slash/deck.ts#L169

The EntityNotFoundError from ManualDeckSubmission.findOneOrFail is not handled, so it propagates up the handlers all the way until the "error" listener on the bot instance logs it. Instead, this should use findOne, and in the null/undefined case, the host should be notified appropriately via Discord, like the 🐌 OUTDATED case.