Skip to content

Commit 509569b

Browse files
LumabotsNeloBlivionLulalabyDA-344
authored
feat: add created_at property to Interaction (#2801)
* feat: add created_at property to Interaction for message creation time * Update CHANGELOG.md * Update discord/interactions.py Co-authored-by: UK <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update CHANGELOG.md Co-authored-by: DA344 <[email protected]> Signed-off-by: Lala Sabathil <[email protected]> --------- Signed-off-by: Lumouille <[email protected]> Signed-off-by: Lala Sabathil <[email protected]> Co-authored-by: UK <[email protected]> Co-authored-by: Lala Sabathil <[email protected]> Co-authored-by: DA344 <[email protected]>
1 parent 1575a27 commit 509569b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ These changes are available on the `master` branch, but have not yet been releas
5353
([#2598](https://github.com/Pycord-Development/pycord/pull/2598))
5454
- Added the ability to change the API's base URL with `Route.API_BASE_URL`.
5555
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
56-
- Added the ability to pass a `datetime.time` object to `format_dt`
56+
- Added the ability to pass a `datetime.time` object to `format_dt`.
5757
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
58+
- Added `discord.Interaction.created_at`.
59+
([#2801](https://github.com/Pycord-Development/pycord/pull/2801))
5860

5961
### Fixed
6062

discord/interactions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from __future__ import annotations
2727

2828
import asyncio
29+
import datetime
2930
from typing import TYPE_CHECKING, Any, Coroutine, Union
3031

3132
from . import utils
@@ -300,6 +301,11 @@ def guild(self) -> Guild | None:
300301
return self._guild
301302
return self._state and self._state._get_guild(self.guild_id)
302303

304+
@property
305+
def created_at(self) -> datetime.datetime:
306+
"""Returns the interaction's creation time in UTC."""
307+
return utils.snowflake_time(self.id)
308+
303309
def is_command(self) -> bool:
304310
"""Indicates whether the interaction is an application command."""
305311
return self.type == InteractionType.application_command

0 commit comments

Comments
 (0)