diff options
| author | 2021-03-08 17:30:58 +0100 | |
|---|---|---|
| committer | 2021-03-08 17:30:58 +0100 | |
| commit | 0a2e08c28d0dc6ca523bdf421a4759d9c38d8a3f (patch) | |
| tree | 39544c70ea38ce7ba2da206042272e23951ff80e | |
| parent | Make the snowflake command accept many snowflakes (diff) | |
Restrict non-staffer to one snowflake at the time
| -rw-r--r-- | bot/exts/utils/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py index 1a5ded7a8..a5d6f69b9 100644 --- a/bot/exts/utils/utils.py +++ b/bot/exts/utils/utils.py @@ -2,7 +2,7 @@ import difflib import logging import re import unicodedata -from typing import Tuple, Union, List +from typing import Tuple, Union from discord import Colour, Embed, utils from discord.ext.commands import BadArgument, Cog, Context, clean_content, command, has_any_role @@ -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__) @@ -158,6 +159,9 @@ class Utils(Cog): @in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES) async def snowflake(self, ctx: Context, *snowflakes: Snowflake) -> None: """Get Discord snowflake creation time.""" + 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( |