diff options
| author | 2022-09-16 17:44:56 +0100 | |
|---|---|---|
| committer | 2022-09-16 17:44:56 +0100 | |
| commit | 95124cafd0b23c7e4bb2c0c19b3a043f17184ef2 (patch) | |
| tree | 8082f4527467badb5bf5c3e61500e89936bbd958 | |
| parent | replace .isdigit predicate with a try except block (diff) | |
rename rules to rule_numbers
| -rw-r--r-- | bot/exts/info/information.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py index b66c68f87..c706fa4cd 100644 --- a/bot/exts/info/information.py +++ b/bot/exts/info/information.py @@ -526,15 +526,15 @@ class Information(Cog): Rule numbers and keywords can be sent in any order. """ rules_embed = Embed(title="Rules", color=Colour.og_blurple(), url="https://www.pythondiscord.com/pages/rules") - keywords, rules = [], [] + keywords, rule_numbers = [], [] for word in args: try: - rules.append(int(word)) + rule_numbers.append(int(word)) except ValueError: keywords.append(word.lower()) - if not rules and not keywords: + if not rule_numbers and not keywords: # Neither rules nor keywords were submitted. Return the default description. rules_embed.description = ( "The rules and guidelines that apply to this community can be found on" @@ -548,11 +548,11 @@ class Information(Cog): full_rules = await self.bot.api_client.get("rules", params={"link_format": "md"}) # Remove duplicates and sort the rule indices - rules = sorted(set(rules)) + rule_numbers = sorted(set(rule_numbers)) # Remove duplicate keywords keywords = set(keywords) - invalid = ", ".join(str(index) for index in rules if index < 1 or index > len(full_rules)) + invalid = ", ".join(str(index) for index in rule_numbers if index < 1 or index > len(full_rules)) if invalid and not keywords: await ctx.send(shorten(":x: Invalid rule indices: " + invalid, 75, placeholder=" ...")) @@ -560,7 +560,7 @@ class Information(Cog): final_rules = set() - for pick in rules: + for pick in rule_numbers: self.bot.stats.incr(f"rule_uses.{pick}") final_rules.add( f"**{pick}.** {full_rules[pick - 1][0]}\n\n" @@ -578,7 +578,7 @@ class Information(Cog): f"You can also invoke this rule with the following keywords: " f"{', '.join(full_rules[pick][1])}") - if not rules and not final_rules: + if not rule_numbers and not final_rules: # This would mean that only keywords where used and no match for them was found await ctx.send( f"There are currently no rules that correspond to keywords: **{', '.join(keywords)}**.\n" |