macizo-hook / discord-blaine-bot

A fun Pokémon themed quiz bot for Discord.
3 stars 2 forks source link

Revise "award_role" to provide different roles, maybe re-work logic #7

Open macizo-hook opened 1 year ago

macizo-hook commented 1 year ago

It would be neat to experiment with different ways to offer awards! For example, what if the awarded role name was randomized from a bank of Pokemon Anime/Manga/Game quotes?

macizo-hook commented 1 year ago

This is a fun one.

believemanasseh commented 1 year ago

Mind expatiating on the "bank of Pokemon Anime/Manga/Game quotes"? Currently, I can see three role names awarded based on percentage. Should there be more roles awarded randomly regardless of percentage? (Ps: I don't know anything about Pokemon)

macizo-hook commented 1 year ago

@believemanasseh Absolutely!

"bank of Pokemon Anime/Manga/Game quotes"?

Assuming there exists a Redis set named "role_names" that contains role_names, we should be able to add new role_names:

r.sadd("role_names", "Role1")
r.sadd("role_names", "Role2")
r.sadd("role_names", "Role3")

The award_role function can be modified to fetch the role names from Redis, and select one randomly (I'm taking a guess at the logic here):

  try:
        # Fetch the role_names from redis
        role_names = r.smembers("role_names")

        if not role_names:
            await ctx.send("No roles available. Sorry lol")
            return

        # Select a random role name
        role_name = random.choice(list(role_names))

        # If the role doesn't exist, then create it.
        role = get(ctx.guild.roles, name=role_name)
        if not role:
            role = await ctx.guild.create_role(name=role_name)

Should there be more roles awarded randomly regardless of percentage?

We may consider the concept of "role_thresholds"? Example:

 role_thresholds = [
        {"min_percentage": 80, "name": "role_name"},
        {"min_percentage": 50, "name": "role_name"},
        {"min_percentage": 0, "name": "role_name"},
    ]
macizo-hook commented 1 year ago

@believemanasseh

(Ps: I don't know anything about Pokemon)

This is a real issue, and I can fix it :-D