interactions-py / interactions.py

A highly extensible, easy to use, and feature complete bot framework for Discord
https://interactions-py.github.io/interactions.py/
MIT License
839 stars 184 forks source link

[BUG] Phantom `timestamp` being added to Embeds at HTTP POST response #684

Closed V3ntus closed 2 years ago

V3ntus commented 2 years ago

Describe the bug.

Users are reporting a timestamp field is being added onto embeds when it reaches Discord, even though they did not set timestamp to anything

List the steps.

Create a simple embed and send it normally

What you expected.

No timestamp

What you saw.

DEBUG:http:POST: https://discord.com/api/v10/interactions/.../.../callback: {'json': {'type': 4, 'data': {'content': '', 'tts': False, 'embeds': [..., 'timestamp': '2022-03-29T19:21:06.721804'}],

Oddly this is being added during a mixin iteration

Here: https://github.com/interactions-py/library/blob/711ae0ff020ca91f9102f966581ee47ff1c9725a/interactions/api/models/message.py#L1032

What version of the library did you use?

unstable

Version specification

No response

Code of Conduct

V3ntus commented 2 years ago

Possibly linked with #683 in some way? Maybe?

Edit: probably not

EepyElvyra commented 2 years ago

hrm

if you check data before and after hit, one has timestamp set to none, in the other its not present

that could be the issue, since I remove None values from the dicts..

V3ntus commented 2 years ago

Not exactly sure what you mean, sorry

Considering this code in api/models/message.py, if timestamp is None, it adds utcnow, it doesn't do any sort of removing

def __init__(self, **kwargs):
    super().__init__(**kwargs)
    self.timestamp = (
        datetime.fromisoformat(self._json.get("timestamp"))
        if self._json.get("timestamp")
        else datetime.utcnow()
    )
EepyElvyra commented 2 years ago

grafik

i remove None values, maybe that's the issue there?

V3ntus commented 2 years ago

Oh yeah this happens without the presence of timestamp in my Embed object too. I was testing to see if timestamp=None would do anything different

i0bs commented 2 years ago

Hey! We've fixed this on our unstable branch and will be closing this now. 😄