Skip to content

Commit

Permalink
Dynamically patch message.created_at attribute to data
Browse files Browse the repository at this point in the history
  • Loading branch information
weibeu committed Mar 28, 2020
1 parent 545e6af commit cddbbbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion discordDB/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ async def get(self, _id: int) -> Data:
"""
message = await self.channel.fetch_message(_id)
_data = message.embeds[0].to_dict()["fields"]
return Data({_["name"]: _["value"] for _ in _data})
data = Data({_["name"]: _["value"] for _ in _data})
data.created_at = message.created_at
return data
10 changes: 9 additions & 1 deletion discordDB/models/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
class Data(dict):
"""Actually a superset class of python dictionaries, which also supports accessing of its keys using . syntax."""
"""Actually a superset class of python dictionaries, which also supports accessing of its keys using . syntax.
Extra Attributes
----------------
created_at : datetime.datetime
The time this data was created in UTC.
"""

def __getattribute__(self, item):
try:
Expand Down

0 comments on commit cddbbbc

Please sign in to comment.