aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2022-11-02 14:28:52 +0000
committerGravatar GitHub <[email protected]>2022-11-02 14:28:52 +0000
commitdd226ad86f0f9927906734546a6cfaa7820a82cf (patch)
treeb10ffa4be0ae0600dd432a75e4ef2392a3fe2dcc
parentMerge pull request #2315 from python-discord/bug/2299/timeit (diff)
parentMerge branch 'main' into issue-2280-rule-keywords-discoverability (diff)
Merge pull request #2309 from shtlrs/issue-2280-rule-keywords-discoverability
-rw-r--r--bot/exts/info/information.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py
index 2eb9382e3..733597dd8 100644
--- a/bot/exts/info/information.py
+++ b/bot/exts/info/information.py
@@ -523,6 +523,17 @@ class Information(Cog):
"""Shows information about the raw API response in a copy-pasteable Python format."""
await self.send_raw_content(ctx, message, json=True)
+ async def _set_rules_command_help(self) -> None:
+ help_string = f"{self.rules.help}\n\n"
+ help_string += "__Available keywords per rule__:\n\n"
+
+ full_rules = await self.bot.api_client.get("rules", params={"link_format": "md"})
+
+ for index, (_, keywords) in enumerate(full_rules, start=1):
+ help_string += f"**Rule {index}**: {', '.join(keywords)}\n\r"
+
+ self.rules.help = help_string
+
@command(aliases=("rule",))
async def rules(self, ctx: Context, *, args: Optional[str]) -> Optional[Set[int]]:
"""
@@ -580,6 +591,10 @@ class Information(Cog):
return final_rule_numbers
+ async def cog_load(self) -> None:
+ """Carry out cog asynchronous initialisation."""
+ await self._set_rules_command_help()
+
async def setup(bot: Bot) -> None:
"""Load the Information cog."""