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

Found a bug. Needs to be fixed urgently. #3

Closed DevInfinix closed 3 years ago

DevInfinix commented 3 years ago

Hi @Defxult ! I just found a new bug while I was testing my code.


ISSUE:

  • The issue I am currently facing is, the database file (.db) created using the DiscordLevelingSystem.create_database_file(file_path: str) method only registers the member id as the primary key in leaderboard table, while the guild id doesn't get registered.
  • I checked out the code of class DiscordLevelingSystem (leveling_system.py), I couldn't find any code which registers the guild in the leaderboard table. This means the bot would only update the leaderboard table when the member/author sends a message, regardless of being in the same guild or a different one.
  • I levelled up to 1 in a server and my next level in another server was level 2 (while testing the code).
  • The member's level and XP shouldn't remain the same in all the servers.

Probably not a bug:

  • The member data cannot be accessed from await DiscordLevelingSystem.get_data_for(member: Member) method.
  • Please provide an example using the class MemberData in the readme.md file.

Requesting you to please resolve this issue as soon as possible. Thank you

Defxult commented 3 years ago

You're right. When developing this library I only did my testing in a single server so the thought of that issue never came up. I'll see what I can do about it and if I find a solution it will fixed next update.

As for the MemberData example, the README.md will be updated as well with the next update. But for now here is an example

lvl = DiscordLevelingSystem(...)

@bot.command()
async def example(ctx):
    data = await lvl.get_data_for(ctx.author)
    await ctx.send(f"{ctx.author.name} has {data.total_xp} XP")

All attributes for MemberData are located in the readme