discord-tickets / bot

The most popular open-source and self-hosted ticket management bot for Discord - a free alternative to the premium and white-label plans of other popular ticketing bots.
https://discordtickets.app
GNU General Public License v3.0
880 stars 459 forks source link

[BUG] Tickets closed without staff response count as open #499

Closed VinDotRun closed 8 months ago

VinDotRun commented 8 months ago

Is there an existing issue for this?

Current Behavior

Tickets can be closed with no firstResponseAt value. Tickets that are closed, but have a null value in the firstResponseAt column are counted as open when updating the bot's presence.

Expected Behavior

The value of firstResponseAt shouldn't be taken into consideration when calculating how many tickets are closed.

Steps To Reproduce

  1. In the config.yml file, add an activity that uses the {openTickets} variable.
  2. Create a new ticket.
  3. Restart the bot to flush the cache and immediately update the bot's presence.
  4. Observe the number of open tickets in the bot's presence. It should now be 1.
  5. Close the ticket without sending any messages from a staff member's account in the ticket channel.
  6. Restart the bot once again to flush the cache.
  7. Observe that the number of open tickets in the bot's presence remains unchanged.
  8. Inspect the tickets table in the database. Find the ticket, copy the value of closedAt and paste it into firstResponseAt.
  9. Restart the bot to flush the cache and update the bot's presence.
  10. Watch that the number of open tickets in the bot's presence has decreased to 0.

Environment

- OS: Ubuntu 20.04 LTS
- Node: 18.16.1
- NPM: 9.5.1
- Bot: 4.0.10

Anything else?

Problem seems to have been introduced with the commit below.

Ref: https://github.com/discord-tickets/bot/commit/ced14ce36a37a7ecb9fd66e93650f3579955516a#diff-ab800e8822d27668fda582dd3ae55a1b9b0fbf998275dd45af59f0f3ce70edd3