aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Amrou Bellalouna <[email protected]>2022-10-23 11:25:33 +0100
committerGravatar Amrou Bellalouna <[email protected]>2022-10-23 11:25:33 +0100
commit8bd4eac381063f9f8da221bd4bd7f0a98b35dd3f (patch)
tree0292262e494f1d59ec4642b8ad3f84f7453f946b
parentMerge pull request #2298 from shtlrs/issue-2294-zen-command (diff)
set rules command's help upon cog_load
-rw-r--r--bot/exts/info/information.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py
index 2592e093d..6b012c222 100644
--- a/bot/exts/info/information.py
+++ b/bot/exts/info/information.py
@@ -523,14 +523,23 @@ 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)
- @command(aliases=("rule",))
- async def rules(self, ctx: Context, *args: Optional[str]) -> Optional[Set[int]]:
+ async def _set_rules_command_help(self) -> None:
+ help_string = """
+ Provides a link to all rules or, if specified, displays specific rule(s).\n
+ It accepts either rule numbers or particular keywords that map to a particular rule.\n
+ Rule numbers and keywords can be sent in any order.\n\n
+ Available keywords per rule:\n
"""
- Provides a link to all rules or, if specified, displays specific rule(s).
- It accepts either rule numbers or particular keywords that map to a particular rule.
- Rule numbers and keywords can be sent in any order.
- """
+ 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 n°{index}**: {', '.join(keywords)}\n\n"
+
+ self._rules.help = help_string
+
+ @command(aliases=("rule",))
+ async def _rules(self, ctx: Context, *args: Optional[str]) -> Optional[Set[int]]:
rules_embed = Embed(title="Rules", color=Colour.og_blurple(), url="https://www.pythondiscord.com/pages/rules")
keywords, rule_numbers = [], []
@@ -578,7 +587,12 @@ 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."""
await bot.add_cog(Information(bot))
+ log.info("Cog loaded: Information")