Swiddis / word-debt-bot

A Discord bot for running a little reading game.
MIT License
2 stars 2 forks source link

Genre tagging and notes on log command #9

Closed azhitian closed 6 months ago

azhitian commented 6 months ago

Users need to be able to add genres to their logs for implementation of the Bonus Genre shop item. Some users also like to add notes so that they can remember what it is they were logging.

@commands.command(name="log")
async def log(self, ctx, words: int):
    if not self.game:
        await ctx.send("Game not loaded. (Yell at Toast!)")
        return
    try:
        new_debt = self.game.submit_words(str(ctx.author.id), words)
        self.journal({"command": "log", "words": words, "user": str(ctx.author.id)})
        await ctx.send(f"Logged {words:,} words! New debt: {new_debt:,}")
    except KeyError as _err:
        await ctx.send("Not registered! `.register`")
    except ValueError as err:
        await ctx.send(f"Error: {str(err)}")

You could change words above to a keyword-only argument as in this link:

https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html#keyword-only-arguments

and parse the user's input yourself with regex. I recommend the syntax 12345 [genre] (note).

Will make the code a little less pretty, but I think it's a solution that's relatively easy for end-users to understand.

The "Logged X words!" message should also be updated to let the user know which part of the their message was treated as genre and note, and also if they genre they used is an active Bonus Genre.

azhitian commented 6 months ago

An even simpler and more transparent solution might be to just add a .bonuslog command, but this doesn't open up the possibility for more behavior around genres and notes later. Either solution relies on some self policing, and the .bonuslog might require a little more.

If there's a status/leaderboard command at some point later, it some definitely include whether a bonus genre is active (in addition to the states of other items, rewards, counts)

Swiddis commented 6 months ago

Might be worth waiting for an implementation for #14 to see how to add this, since they'll probably be related

Swiddis commented 6 months ago

Completed in hotfix #29