merlinfuchs / embed-generator

Create rich embed messages for Discord (previously discord.club)
https://message.style
MIT License
292 stars 35 forks source link

Able to import embeds from JSON #113

Closed oxydien closed 10 months ago

oxydien commented 11 months ago

Have a button in the app that would allow the user to paste JSON, and then import it. Or maybe in the code modal, editing would work.

merlinfuchs commented 11 months ago

You can already do that in the JSON code modal. You can paste stuff and edit it

oxydien commented 11 months ago

Sorry i noticed that too late :). The reason that i couldn't do it earlier, is because i was pasting the discord raw from already sent message...

merlinfuchs commented 11 months ago

You should be able to paste the JSON code of an existing Discord message

oxydien commented 11 months ago

So i think that there is error in there with the id... In discord raw message embed the id is string.

Error:

ZodError: [
  {
    "code": "invalid_type",
    "expected": "number",
    "received": "string",
    "path": [
      "embeds",
      0,
      "id"
    ],
    "message": "Expected number, received string"
  },
  {
    "code": "invalid_type",
    "expected": "number",
    "received": "string",
    "path": [
      "embeds",
      0,
      "color"
    ],
    "message": "Expected number, received string"
  }
]

What i pasted from discord:

"embeds": [
        {
            "id": "embed_17",
            "type": "rich",
            "rawTitle": "Testing",
            "rawDescription": "embed",
            "contentScanVersion": 0,
            "color": "hsla(198, calc(var(--saturation-factor, 1) * 100%), 50%, 1)",
            "fields": []
        }
    ],
merlinfuchs commented 10 months ago

Hey, beside the id I'm a bit confused about the rawTitle and rawDescription properties. Where did you get this embed JSON from? According to the Discord docs these properties don't exist and the color property should be an integer 🤔

oxydien commented 10 months ago

Oh sorry, I did not notice this... So I'm using Vencord and there is plugin ViewRaw that I used... But I did not know that the embeds would be different, because everything else looks the same as in the normal message response. So from discord it works:

"embeds": [
  {
      "type": "rich",
      "title": "Testing",
      "description": "embed",
      "color": 45823,
      "content_scan_version": 0
  }
]

Sorry that i did not notice this earlier. I think that the raw data from the embed is taken directly from the client and that's why it does not match...

merlinfuchs commented 10 months ago

Ah I see. Yeah I don't think I want to support the different format of the client