diff options
| author | 2022-09-08 23:11:41 +0100 | |
|---|---|---|
| committer | 2022-09-08 23:11:41 +0100 | |
| commit | 357ed80e2a0f35172ca91ceda7a353a4a8f765dd (patch) | |
| tree | 73db25ef8e0f622f9d9bcc6d53143517190c32d4 | |
| parent | add support for keywords when using the "rules" command. (diff) | |
send the list of pre-defined keywords along with each invoked rule
| -rw-r--r-- | bot/exts/info/information.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py index d53f4e323..54fa62d31 100644 --- a/bot/exts/info/information.py +++ b/bot/exts/info/information.py @@ -521,6 +521,7 @@ class Information(Cog): async def rules(self, ctx: Context, rules: Greedy[int], keyword: Optional[str]) -> None: """Provides a link to all rules or, if specified, displays specific rule(s).""" rules_embed = Embed(title="Rules", color=Colour.og_blurple(), url="https://www.pythondiscord.com/pages/rules") + keyword = keyword.lower() if not rules and not keyword: # Neither rules nor keywords were submitted. Return the default description. @@ -548,9 +549,13 @@ class Information(Cog): self.bot.stats.incr(f"rule_uses.{rule}") if rules: - final_rules = tuple(f"**{pick}.** {full_rules[pick - 1][0]}" for pick in rules) + final_rules = tuple(f"**{pick}.** {full_rules[pick - 1][0]}\n\n" + f"You can also invoke this rule with the following keywords: " + f"{', '.join(full_rules[pick -1][1])}" for pick in rules) else: - final_rules = tuple(f"**{pick + 1}** {full_rules[pick][0]}" for pick, rule in enumerate(full_rules) + final_rules = tuple(f"**{pick + 1}** {full_rules[pick][0]}\n\n" + f"You can also invoke this rule with the following keywords: " + f"{', '.join(full_rules[pick][1])}" for pick, rule in enumerate(full_rules) if keyword in rule[1]) if not rules and not final_rules: |