From 9e4b78b40b407c2bb6d4666767d700b7993a54e5 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Fri, 4 Dec 2020 14:46:50 +0200 Subject: Create command for showing Discord snowflake creation time --- bot/exts/utils/utils.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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: -- cgit v1.2.3 From 9d00ef35afd5b64c070003a7941cc38d98bdf9cc Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Wed, 9 Dec 2020 07:56:21 +0200 Subject: Add sf alias to snowflake command --- bot/exts/utils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py index 3f16bc10b..87abbe4de 100644 --- a/bot/exts/utils/utils.py +++ b/bot/exts/utils/utils.py @@ -168,7 +168,7 @@ class Utils(Cog): embed.description = best_match await ctx.send(embed=embed) - @command(aliases=("snf", "snfl")) + @command(aliases=("snf", "snfl", "sf")) @in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES) async def snowflake(self, ctx: Context, snowflake: int) -> None: """Get Discord snowflake creation time.""" -- cgit v1.2.3 From 47a2607ac85c7cf808152c301fb6969723915389 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Thu, 10 Dec 2020 15:39:09 +0200 Subject: Use Snowflake converter for snowflake command --- bot/exts/utils/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py index 87abbe4de..8e7e6ba36 100644 --- a/bot/exts/utils/utils.py +++ b/bot/exts/utils/utils.py @@ -13,6 +13,7 @@ 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 @@ -170,7 +171,7 @@ class Utils(Cog): @command(aliases=("snf", "snfl", "sf")) @in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES) - async def snowflake(self, ctx: Context, snowflake: int) -> None: + async def snowflake(self, ctx: Context, snowflake: Snowflake) -> None: """Get Discord snowflake creation time.""" created_at = snowflake_time(snowflake) embed = Embed( -- cgit v1.2.3