aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2021-06-30 21:23:09 +0200
committerGravatar Numerlor <[email protected]>2021-07-06 02:02:12 +0200
commit7cc8925c681386e20094a918713b5e5b53cea3dd (patch)
tree5660748d40c0268fd40c957e9bc0c258de1e78a6
parentMove tag listing to new design and move it outside of tag display method (diff)
Add option to list all tags in a group
-rw-r--r--bot/exts/info/tags.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/bot/exts/info/tags.py b/bot/exts/info/tags.py
index 4aa590430..2c6dbd29d 100644
--- a/bot/exts/info/tags.py
+++ b/bot/exts/info/tags.py
@@ -319,6 +319,16 @@ class Tags(Cog):
embed = Embed(title="Current tags")
await LinePaginator.paginate(result_lines, ctx, embed=embed, max_lines=15, empty=False, footer_text=FOOTER_TEXT)
+ async def list_tags_in_group(self, ctx: Context, group: str) -> None:
+ """Send a paginator with all tags under `group`, that are accessible by `ctx.author`."""
+ embed = Embed(title=f"**Tags under *{group}***")
+ tag_lines = sorted(
+ f"**\N{RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK}** {identifier}"
+ for identifier, tag in self._tags.items()
+ if identifier.group == group and tag.accessible_by(ctx.author)
+ )
+ await LinePaginator.paginate(tag_lines, ctx, embed, footer_text=FOOTER_TEXT, empty=False, max_lines=15)
+
@tags_group.command(name='get', aliases=('show', 'g'))
async def get_command(
self, ctx: Context,
@@ -340,8 +350,15 @@ class Tags(Cog):
return True
if tag_name is None:
- tag_name = tag_name_or_group
- tag_group = None
+ if any(
+ tag_name_or_group == identifier.group and tag.accessible_by(ctx.author)
+ for identifier, tag in self._tags.items()
+ ):
+ await self.list_tags_in_group(ctx, tag_name_or_group)
+ return True
+ else:
+ tag_name = tag_name_or_group
+ tag_group = None
else:
tag_group = tag_name_or_group