Skip to content

Commit

Permalink
Add the help subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
eandersons committed Mar 9, 2023
1 parent 74dce03 commit 30952b9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ def on_external_config_update(self) -> None:
def get_config_class(cls) -> Type[Config]:
return Config

@command.new("roll")
@command.new(
"roll", help="Roll dice(s), do the math",
arg_fallthrough=False, require_subcommand=False
)
@command.argument("pattern", pass_raw=True, required=False)
async def roll(self, evt: MessageEvent, pattern: str) -> None:
if not pattern:
Expand Down Expand Up @@ -252,3 +255,16 @@ def replacer(match: Match) -> str:
result += "\n".join(f"{number}d{size}: {' '.join(str(result) for result in results)} "
for number, size, results in individual_rolls)
await evt.reply(result)

@roll.subcommand("help", help="Usage instructions")
async def help(self, evt: MessageEvent) -> None:
"""Return help message."""
await evt.respond(
"The base command is `!roll`. \\\n"
"To roll a dice, pass `XdY` as an argument, where `X` is the "
"number of dices (optional) and `Y` is the number of sides on "
"each dice. \\\n"
"Most Python math and bitwise operators and basic `math` module "
"functions are also supported, which means you can roll different "
"kinds of dice and combine the results however you like."
)

0 comments on commit 30952b9

Please sign in to comment.