aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2021-04-14 19:57:37 +0300
committerGravatar GitHub <[email protected]>2021-04-14 19:57:37 +0300
commita8daa2c2f2887ce73aaa56bb65d092f0c99094e3 (patch)
treeb12b5cf88dc6796de029d79cb1f4768c4bfe3362
parentMerge pull request #1525 from python-discord/catch-invocation-not-found-error (diff)
parentMerge branch 'main' into output-snowflakes-in-one-embed (diff)
Merge pull request #1524 from python-discord/output-snowflakes-in-one-embed
Use a paginated embed to output multiple snowflakes
-rw-r--r--bot/exts/utils/utils.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py
index cae7f2593..8d9d27c64 100644
--- a/bot/exts/utils/utils.py
+++ b/bot/exts/utils/utils.py
@@ -162,17 +162,27 @@ class Utils(Cog):
if len(snowflakes) > 1 and await has_no_roles_check(ctx, *STAFF_ROLES):
raise BadArgument("Cannot process more than one snowflake in one invocation.")
+ if not snowflakes:
+ raise BadArgument("At least one snowflake must be provided.")
+
+ embed = Embed(colour=Colour.blue())
+ embed.set_author(
+ name=f"Snowflake{'s'[:len(snowflakes)^1]}", # Deals with pluralisation
+ icon_url="https://github.com/twitter/twemoji/blob/master/assets/72x72/2744.png?raw=true"
+ )
+
+ lines = []
for snowflake in snowflakes:
created_at = snowflake_time(snowflake)
- embed = Embed(
- description=f"**Created at {created_at}** ({time_since(created_at, max_units=3)}).",
- colour=Colour.blue()
- )
- embed.set_author(
- name=f"Snowflake: {snowflake}",
- icon_url="https://github.com/twitter/twemoji/blob/master/assets/72x72/2744.png?raw=true"
- )
- await ctx.send(embed=embed)
+ lines.append(f"**{snowflake}**\nCreated at {created_at} ({time_since(created_at, max_units=3)}).")
+
+ await LinePaginator.paginate(
+ lines,
+ ctx=ctx,
+ embed=embed,
+ max_lines=5,
+ max_size=1000
+ )
@command(aliases=("poll",))
@has_any_role(*MODERATION_ROLES, Roles.project_leads, Roles.domain_leads)