diff options
| author | 2020-12-10 16:01:57 +0200 | |
|---|---|---|
| committer | 2020-12-10 16:01:57 +0200 | |
| commit | cc8b2185bae3a891ff5b5397377e8bee5ac3d3a0 (patch) | |
| tree | 8b93156b96fd105c561b71dfc2dc999f4c9ff144 | |
| parent | Merge pull request #1322 from python-discord/swfarnsworth/developer_command (diff) | |
| parent | Merge branch 'master' into ks123/snowflake-command (diff) | |
Merge pull request #1318 from python-discord/ks123/snowflake-command
Create command for showing Discord snowflake creation time
| -rw-r--r-- | bot/exts/utils/utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py index 6d8d98695..8e7e6ba36 100644 --- a/bot/exts/utils/utils.py +++ b/bot/exts/utils/utils.py @@ -9,13 +9,16 @@ from typing import Dict, Optional, Tuple, Union from discord import Colour, Embed, utils from discord.ext.commands import BadArgument, Cog, Context, clean_content, command, has_any_role +from discord.utils import snowflake_time from bot.bot import Bot from bot.constants import Channels, MODERATION_ROLES, STAFF_ROLES +from bot.converters import Snowflake from bot.decorators import in_whitelist from bot.pagination import LinePaginator from bot.utils import messages from bot.utils.cache import AsyncCache +from bot.utils.time import time_since log = logging.getLogger(__name__) @@ -166,6 +169,21 @@ class Utils(Cog): embed.description = best_match await ctx.send(embed=embed) + @command(aliases=("snf", "snfl", "sf")) + @in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES) + async def snowflake(self, ctx: Context, snowflake: 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) + @command(aliases=("poll",)) @has_any_role(*MODERATION_ROLES) async def vote(self, ctx: Context, title: clean_content(fix_channel_mentions=True), *options: str) -> None: |