Update converter.py
This commit is contained in:
parent
db10f65393
commit
f4191ebf30
@ -26,6 +26,7 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
import inspect
|
||||
import datetime
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
@ -823,7 +824,23 @@ class PartialEmojiConverter(Converter[discord.PartialEmoji]):
|
||||
|
||||
raise PartialEmojiConversionFailure(argument)
|
||||
|
||||
class FormattedDatetimeConverter(Converter[Tuple[datetime.datetime, Optional[str]]]):
|
||||
|
||||
"""Converts a discord style datetime to a :class:`datetime.datetime`.
|
||||
Also returns the flag used to format the timestamp if present.
|
||||
This is done by extracting the epoch from the string.
|
||||
.. versionadd:: 2.0
|
||||
Raise :exc:`.FormattedDatetimeConversionFailure` instead of generic :exc:`.BadArgument`
|
||||
"""
|
||||
|
||||
async def convert(self, ctx: Context, argument: str) -> Tuple[datetime.datetime, Optional[str]]:
|
||||
|
||||
match = discord.utils.resolve_formatted_dt(argument)
|
||||
if match:
|
||||
return match
|
||||
|
||||
raise FormattedDatetimeConversionFailure(argument)
|
||||
|
||||
class GuildStickerConverter(IDConverter[discord.GuildSticker]):
|
||||
"""Converts to a :class:`~discord.GuildSticker`.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user