SGA-A / c2c

Source code for the custom app exclusive to cc
MIT License
1 stars 0 forks source link

Storing Item Use Callbacks #137

Open SGA-A opened 3 months ago

SGA-A commented 3 months ago

I may or may not have opened an issue similar to this in the past, but to no surprise it is difficult to figure out how to approach this one. It seems bundling the item uses in a dictionary seems to be the only option. Still in the process of looking for more alternatives.

SGA-A commented 3 months ago

Seems I have to think of my own solution here, the internet doesn't have any.

This could take months.

SGA-A commented 3 months ago

This pairs alongside the issue: storing item logic within the database, rather than manually carrying them out in each individual item use callback.

For instance, we can create a column named reuse alongside the shop item table to indicate which items are reusable. Then, in the single use slash command callback, we check that it is reusable. If not, deduct the specified quantity from the user. It is frankly disturbing that this has only just been realized.

As for storing connections in the callback, we don't want this happening so from now on, we are simply going to release the currently acquired connection after all item checks pass and before we begin searching for the respective item callback. In the callback itself, we'll need to acquire another connection. Alternatively, we don't and just store the connection in the dataclass we already use: https://github.com/SGA-A/c2c/blob/527a530e4908d78bcdf3032ac154e39fbf98e3d9/cogs/economy.py#L1739-L1741