From 6b0785e4e2030ac2f43cfe5d00f84fba87a921d8 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sun, 1 Jan 2023 17:17:21 +0000 Subject: Add command to refresh devops rules --- arthur/exts/fun/devops_rules.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'arthur/exts/fun/devops_rules.py') diff --git a/arthur/exts/fun/devops_rules.py b/arthur/exts/fun/devops_rules.py index 9c231d8..24c41f2 100644 --- a/arthur/exts/fun/devops_rules.py +++ b/arthur/exts/fun/devops_rules.py @@ -3,7 +3,7 @@ from typing import TypedDict import discord -from discord.ext.commands import Cog, Context, Greedy, command +from discord.ext.commands import Cog, Context, Greedy, group from arthur.bot import KingArthur, logger from arthur.config import CONFIG @@ -72,8 +72,8 @@ class Rules(Cog): if block.get("type") == "numbered_list_item" } - @command(name="rules", aliases=("rule",)) - async def get_rules(self, ctx: Context, rules: Greedy[int]) -> None: + @group(name="rules", aliases=("rule",)) + async def rules_group(self, ctx: Context, rules: Greedy[int]) -> None: """List the requested rule(s), or all of them if not defined.""" if rules: output_rules = set(rules) & set(self.rules.keys()) @@ -96,6 +96,11 @@ class Rules(Cog): url="https://www.notion.so/pythondiscord/Rules-149bc48f6f7947afadd8036f11d4e9a7", )) + @rules_group.command(name="refresh", aliases=("fetch", "update")) + async def update_rules(self, ctx: Context) -> None: + """Re-fetch the list of rules from notion.""" + await self.cog_load() + async def setup(bot: KingArthur) -> None: """Add cog to bot.""" -- cgit v1.2.3 From 7d272f9b5709f6a5f921adf8479e7ad75a1cc4b4 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sun, 1 Jan 2023 17:21:13 +0000 Subject: Format devops rules cog --- arthur/exts/fun/devops_rules.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'arthur/exts/fun/devops_rules.py') diff --git a/arthur/exts/fun/devops_rules.py b/arthur/exts/fun/devops_rules.py index 24c41f2..66b0078 100644 --- a/arthur/exts/fun/devops_rules.py +++ b/arthur/exts/fun/devops_rules.py @@ -85,16 +85,16 @@ class Rules(Cog): return output = "\n".join( - f"{key}: {value}" - for key, value in self.rules.items() - if key in output_rules + f"{key}: {value}" for key, value in self.rules.items() if key in output_rules + ) + await ctx.send( + embed=discord.Embed( + title=f"Rule{'s'[:len(output_rules)^1]}", + description=output, + colour=discord.Colour.og_blurple(), + url="https://www.notion.so/pythondiscord/Rules-149bc48f6f7947afadd8036f11d4e9a7", + ) ) - await ctx.send(embed=discord.Embed( - title=f"Rule{'s'[:len(output_rules)^1]}", - description=output, - colour=discord.Colour.og_blurple(), - url="https://www.notion.so/pythondiscord/Rules-149bc48f6f7947afadd8036f11d4e9a7", - )) @rules_group.command(name="refresh", aliases=("fetch", "update")) async def update_rules(self, ctx: Context) -> None: -- cgit v1.2.3