PonyEventsFederation / CanniJS

Canni Discord Bot
MIT License
4 stars 5 forks source link

[Feature] Add database to Canni #117

Closed ChrisFhey closed 3 years ago

ChrisFhey commented 3 years ago

Describe the feature

Let Canni connect to a database to keep track of cooldowns across restarts.

Why would you like this feature to be added?

Canni currently keeps track of her cooldowns in memory for megaboops, megahugs, etc... This means that she loses these cooldowns upon a restart, be it intentional or not. Adding a database to keep track of this data prevents people from circumventing her cooldowns.

ChrisFhey commented 3 years ago

Initial change has been made to megaboop logic. Next on the list is adding a way to clear the data at midnight.

ChrisFhey commented 3 years ago

Added an event to mysql database that should clear the timeouts every day at 23:59. (Keyword: should)

meadowsys commented 3 years ago

im looking at the code, wouldn't it be better to have a persistent connection to the db instead of connecting and disconnecting everytime?

ChrisFhey commented 3 years ago

While testing I've noticed the server kills the connection after its timeout, and crashes the app when not closing the connection. For now I'll leave it like this so I can test if everything works. I'll look at connection pooling afterwards to fix the crashing.