feat(aurora): added datetime command

This commit is contained in:
Seaswimmer 2024-08-12 20:44:12 -04:00
parent 4ec065e438
commit 9e2bcf9b00
Signed by: cswimr
GPG key ID: 3813315477F26F82

View file

@ -1224,6 +1224,25 @@ class Aurora(commands.Cog):
error("Please provide a valid GalacticBot moderation export file.") error("Please provide a valid GalacticBot moderation export file.")
) )
@aurora.command(aliases=["dtc", "dt", "datetimeconvert"])
async def datetime(self, ctx: commands.Context, *, date: str) -> None:
"""Convert a string to a datetime object.
This command converts a date to a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) Python object.
**Example usage**
`[p]aurora datetime 08/20/2024`
**Output**
`2024-08-20 12:00:00`"""
try:
parsed_date = parse(date)
await ctx.send(f"`{parsed_date}`")
except (ParserError, OverflowError) as e:
if e == ParserError:
await ctx.send(error("Invalid date format!"))
if e == OverflowError:
await ctx.send(error("Date is too far in the future!"))
@aurora.command(aliases=["tdc", "td", "timedeltaconvert"]) @aurora.command(aliases=["tdc", "td", "timedeltaconvert"])
async def timedelta(self, ctx: commands.Context, *, duration: str) -> None: async def timedelta(self, ctx: commands.Context, *, duration: str) -> None:
"""Convert a string to a timedelta. """Convert a string to a timedelta.