Defxult / discordLevelingSystem

A library to implement a leveling system into a discord bot. Contains features such as XP, level, ranks, and role awards.
MIT License
91 stars 17 forks source link

Feature request: Level promotion (json to database) #7

Closed SaviorKnight closed 3 years ago

SaviorKnight commented 3 years ago

Hi @Defxult,

First of thank you for sharing this awesome set of levelling tools. I would like to ask if it would it be possible to add level promotion, what I mean by this at each level cap the experience accumulations stops until a faction to 'promote' a user is called.

Example:

In my mind it would be an setting that skips automated advancement of the user and lets that behaviour be decided outside the library.

I hope it is something that can be added as it would save me allot of time having to start a level system from scratch.

Defxult commented 3 years ago

That’s not something that would be implemented because that would require the library to remember (have a value stored in the database file) who was pending a /promote. Which means a new row would have to be added to the database table, which is massively breaking and another transfer() method would have to be made. I guess the other way would be to have some type of pending pool (just a list of people waiting to receive a /promote, but I don’t think that’s ideal because on bot restart or cog reload that information would be lost.

You said you’d have to start a leveling system from scratch, so I’m assuming you already have one? A json file maybe?

SaviorKnight commented 3 years ago

I can fully understand it was also a bit of a long shot to ask. I currently have a very basic xp system that ranks just on xp without levels. And it indeed stores this in json files but the rewrite would use a database to later expose the ranking on a web page as well to gain additional xp there. This change came about as I wanted to introduce tasks/challenges at thresholds that could be unlocked by doing certain actions (think be active in voice for 10 minutes or post on the site).

I however thought it could be done purely in code by adding a check if a certain parameter was set on creating the LevelingSystem that would block at every level xp limit and would only add xp again once that limit has passed. So then the external code would check the /promote command conditions and call award_xp function again but with an optional allowLevelUp as a parameter.

I agree not a really clean way but it was a thought on how it could be done without any breaking changes, if you think this may be an addition I would be very thankful but I can fully understand if you would like to close the request.

Thank you again for this library

Defxult commented 3 years ago

I see. It's funny that you submitted this issue today because yesterday I thought it would be cool if people could somehow transfer their current leveling system information (their currently using a json file as their database) into my library's database file. But as I was thinking about it I had some difficulties on how I would implement it. It is possible though and would be a nice feature considering a lot of people watch those leveling system tutorials on YouTube which pretty much all are using json files for their system. Tell you what, I'll try and come up with an efficient way to implement that feature, if I'm successful, I'll ping you here to let you know that it's been implemented. If not, the labels that I have attached to this issue will be removed upon close.

SaviorKnight commented 3 years ago

Thank you.

Defxult commented 3 years ago

@SaviorKnight I've done my rounds of testing and seems to work well. You can find the documentation for it here . If you (or anyone else that reads this issue) runs into any problems, please don't hesitate to report it. Thanks!