[Modlog] add timestamp to [p]casesfor and [p]case (#4137)

* add timestamp to casesfor and case

* [Casereader] add timestamp + i18nify

* of course it was needed...

* Update redbot/cogs/modlog/modlog.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/modlog/modlog.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* well that was easier than expected

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* thx for the help jack

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Dav 2020-08-13 21:17:02 +00:00 committed by GitHub
parent 8e611b466e
commit 914f82f352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,14 +1,14 @@
from datetime import timezone
from datetime import datetime, timezone
from typing import Optional, Union
import discord
from redbot.core import checks, modlog, commands
from redbot.core import checks, commands, modlog
from redbot.core.bot import Red
from redbot.core.i18n import Translator, cog_i18n
from redbot.core.utils.chat_formatting import box
from redbot.core.utils.menus import menu, DEFAULT_CONTROLS
from redbot.core.utils.menus import DEFAULT_CONTROLS, menu
_ = Translator("ModLog", __file__)
@ -117,7 +117,13 @@ class ModLog(commands.Cog):
if await ctx.embed_requested():
await ctx.send(embed=await case.message_content(embed=True))
else:
await ctx.send(await case.message_content(embed=False))
message = _("{case}\n**Timestamp:** {timestamp}").format(
case=await case.message_content(embed=False),
timestamp=datetime.utcfromtimestamp(case.created_at).strftime(
"%Y-%m-%d %H:%M:%S UTC"
),
)
await ctx.send(message)
@commands.command()
@commands.guild_only()
@ -143,8 +149,18 @@ class ModLog(commands.Cog):
return await ctx.send(_("That user does not have any cases."))
embed_requested = await ctx.embed_requested()
rendered_cases = [await case.message_content(embed=embed_requested) for case in cases]
if embed_requested:
rendered_cases = [await case.message_content(embed=True) for case in cases]
elif not embed_requested:
rendered_cases = []
for case in cases:
message = _("{case}\n**Timestamp:** {timestamp}").format(
case=await case.message_content(embed=False),
timestamp=datetime.utcfromtimestamp(case.created_at).strftime(
"%Y-%m-%d %H:%M:%S UTC"
),
)
rendered_cases.append(message)
await menu(ctx, rendered_cases, DEFAULT_CONTROLS)