mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-14 22:02:07 +00:00
Add Interaction creation/expiry attributes and helper method
Co-authored-by: Danny <Rapptz@users.noreply.github.com>
This commit is contained in:
parent
8360e4af8d
commit
c907bec753
@ -27,6 +27,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Tuple, Union
|
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Tuple, Union
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import datetime
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .enums import try_enum, InteractionType, InteractionResponseType
|
from .enums import try_enum, InteractionType, InteractionResponseType
|
||||||
@ -222,6 +223,20 @@ class Interaction:
|
|||||||
}
|
}
|
||||||
return Webhook.from_state(data=payload, state=self._state)
|
return Webhook.from_state(data=payload, state=self._state)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_at(self) -> datetime.datetime:
|
||||||
|
""":class:`datetime.datetime`: When the interaction was created."""
|
||||||
|
return utils.snowflake_time(self.id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def expires_at(self) -> datetime.datetime:
|
||||||
|
""":class:`datetime.datetime`: When the interaction expires."""
|
||||||
|
return self.created_at + datetime.timedelta(minutes=15)
|
||||||
|
|
||||||
|
def is_expired(self) -> bool:
|
||||||
|
""":class:`bool`: Returns ``True`` if the interaction is expired."""
|
||||||
|
return utils.utcnow() >= self.expires_at
|
||||||
|
|
||||||
async def original_message(self) -> InteractionMessage:
|
async def original_message(self) -> InteractionMessage:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user