diff options
| author | 2020-12-04 14:46:50 +0200 | |
|---|---|---|
| committer | 2020-12-04 14:46:50 +0200 | |
| commit | 9e4b78b40b407c2bb6d4666767d700b7993a54e5 (patch) | |
| tree | 8161e1ad7a1540b70e0676374cfb8be8f69ca4f3 | |
| parent | Merge PR #1214 - Gracefully handle socket.gaierro in AsyncStatsClient (diff) | |
Create command for showing Discord snowflake creation time
| -rw-r--r-- | bot/exts/utils/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py index 6d8d98695..3f16bc10b 100644 --- a/bot/exts/utils/utils.py +++ b/bot/exts/utils/utils.py @@ -9,6 +9,7 @@ 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 @@ -16,6 +17,7 @@ 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 +168,21 @@ class Utils(Cog): embed.description = best_match await ctx.send(embed=embed) + @command(aliases=("snf", "snfl")) + @in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES) + async def snowflake(self, ctx: Context, snowflake: int) -> 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: |