zaida04 / g.js-self

[archive] Library for creating selfbots on Guilded.
MIT License
54 stars 10 forks source link

refactor: richembed fixes #7

Closed logan-mcgee closed 3 years ago

logan-mcgee commented 3 years ago

Please describe the changes this PR makes and why it should be merged:

Status [x] Code changes have been tested. [x] I know how to update typings and have done so, or typings don't need updating

Semantic versioning classification:

[x] This PR changes the library's interface (methods or parameters added) [] This PR includes breaking changes (methods removed or renamed, parameters moved or removed) [] This PR only includes non-code changes, like changes to documentation, README, etc.

logan-mcgee commented 3 years ago

just for if this fails and im too lazy, issue is that you are lacking some guilded data (e.g. url in author) + the fact that icon_url should be iconUrl in the richembed, causing them to not function in embeds

logan-mcgee commented 3 years ago

i really shouldnt touch things

logan-mcgee commented 3 years ago

will close, i will re-do this without breaking changes and an actual brain

zaida04 commented 3 years ago

Huh, I find it odd that icon_url isn't working. This surprises me because the guildedapi community documentation shows that field is what is correct: image

This property is also what other libraries such as gapi use. Has your iconUrl change actually been tested against the API?

logan-mcgee commented 3 years ago

hm, this is awkward, would appear that for some reason now the icon_url is working fine? at least from reading up in chat messages of testing, where there used to be no image, there actually is now. my reason for doing this was looking at a github webhook, they seem to use iconUrl, which i then tried by hackily overwriting the toJSON function of richembed to use iconUrl, and it worked fine. definitely strange looking back, as some of the embeds i made (using the exact structure of the github embed) are lacking the icon, while some that didnt do now. Either way, the url param doesnt work on author at least, my bad though.

logan-mcgee commented 3 years ago
{
  "data": {
    "embeds": [
      {
        "url": "https://example.com/more",
        "color": 6255313,
        "title": "1 new commit",
        "author": {
          "url": "https://example.com",
          "name": "user",
          "iconUrl": "https://avatars.githubusercontent.com/u/7461476?v=4"
        },
        "description": "some descr"
      }
    ]
  },
  "type": "webhookMessage",
  "nodes": [],
  "object": "block"
}

here is an example of the data layout from the github webhook, which is using iconUrl, which i then tested for footer and also allowed me to use an icon there

logan-mcgee commented 3 years ago

just did another test, modifying the toJSON to use icon_url for author + footer, and one with iconUrl, and this is what i got (forgot to remove the url parameter from author here, hence why that also works): image

shayypy commented 3 years ago

That's really interesting behavior (but not too unusual given Guilded's tendency to prefer camelCase).

The icon_url property displays on mobile and not desktop - so I had assumed it was just an inconsistency. I tested this for myself and using iconUrl instead does indeed display properly on both platforms. I've updated the API documentation (https://github.com/GuildedAPI/docs/commit/91e91946f6a19a2ab8aef4b5c5b0a24dff129c50) to reflect this, as well as my lib (https://github.com/shayypy/guilded.py/commit/38fe80370fa26fea58cacc3de87b6eab10a50fbc), and I encourage others to do the same.

Apologies for the necropost. Thanks @sadboilogan for discovering this