Improve and add more usage of discord timestamps (#5241)

* Improve and add more usage of discord timestamps

* How did that whitespace get there?
This commit is contained in:
jack1142 2021-09-04 09:14:05 +02:00 committed by GitHub
parent 4366af6f6c
commit a0a433b13d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -254,7 +254,7 @@ class General(commands.Cog):
Default to False. Default to False.
""" """
guild = ctx.guild guild = ctx.guild
created_at = _("Created on <t:{0}:D>. That's <t:{0}:R>!").format( created_at = _("Created on <t:{0}>. That's <t:{0}:R>!").format(
int(guild.created_at.replace(tzinfo=datetime.timezone.utc).timestamp()), int(guild.created_at.replace(tzinfo=datetime.timezone.utc).timestamp()),
) )
online = humanize_number( online = humanize_number(

View File

@ -643,7 +643,7 @@ class KickBanMixin(MixinMeta):
with contextlib.suppress(discord.HTTPException): with contextlib.suppress(discord.HTTPException):
# We don't want blocked DMs preventing us from banning # We don't want blocked DMs preventing us from banning
msg = _("You have been temporarily banned from {server_name} until {date}.").format( msg = _("You have been temporarily banned from {server_name} until {date}.").format(
server_name=guild.name, date=unban_time.strftime("%m-%d-%Y %H:%M:%S") server_name=guild.name, date=f"<t:{int(unban_time.timestamp())}>"
) )
if guild_data["dm_on_kickban"] and reason: if guild_data["dm_on_kickban"] and reason:
msg += _("\n\n**Reason:** {reason}").format(reason=reason) msg += _("\n\n**Reason:** {reason}").format(reason=reason)

View File

@ -205,9 +205,9 @@ class ModInfo(MixinMeta):
+ 1 + 1
) )
created_on = "<t:{0}:D>\n(<t:{0}:R>)".format(user_created) created_on = "<t:{0}>\n(<t:{0}:R>)".format(user_created)
if joined_at is not None: if joined_at is not None:
joined_on = "<t:{0}:D>\n(<t:{0}:R>)".format(int(joined_at.timestamp())) joined_on = "<t:{0}>\n(<t:{0}:R>)".format(int(joined_at.timestamp()))
else: else:
joined_on = _("Unknown") joined_on = _("Unknown")

View File

@ -527,7 +527,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
if duration: if duration:
duration_str = humanize_timedelta(timedelta=duration) duration_str = humanize_timedelta(timedelta=duration)
until = datetime.now(timezone.utc) + duration until = datetime.now(timezone.utc) + duration
until_str = until.strftime("%Y-%m-%d %H:%M:%S UTC") until_str = f"<t:{int(until.timestamp())}>"
if moderator is None: if moderator is None:
moderator_str = _("Unknown") moderator_str = _("Unknown")