aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2021-03-12 17:14:06 +0100
committerGravatar GitHub <[email protected]>2021-03-12 17:14:06 +0100
commit7f531a039012fd0fd8ccde13b9a64d7b15043b03 (patch)
treeeb3da0431db9114649ef29e085aad8046e022acb
parentFix typo in the token remover (diff)
parentMerge branch 'master' into many-snowflakes (diff)
Merge pull request #1455 from python-discord/many-snowflakes
Allow the sf command to take more than one snowflake at the time
-rw-r--r--bot/exts/utils/utils.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py
index eb92dfca7..a5d6f69b9 100644
--- a/bot/exts/utils/utils.py
+++ b/bot/exts/utils/utils.py
@@ -14,6 +14,7 @@ from bot.converters import Snowflake
from bot.decorators import in_whitelist
from bot.pagination import LinePaginator
from bot.utils import messages
+from bot.utils.checks import has_no_roles_check
from bot.utils.time import time_since
log = logging.getLogger(__name__)
@@ -156,18 +157,22 @@ class Utils(Cog):
@command(aliases=("snf", "snfl", "sf"))
@in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES)
- async def snowflake(self, ctx: Context, snowflake: Snowflake) -> None:
+ async def snowflake(self, ctx: Context, *snowflakes: Snowflake) -> None:
"""Get Discord snowflake creation time."""
- 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)
+ if len(snowflakes) > 1 and await has_no_roles_check(ctx, *STAFF_ROLES):
+ raise BadArgument("Cannot process more than one snowflake in one invocation.")
+
+ 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)
@command(aliases=("poll",))
@has_any_role(*MODERATION_ROLES)