AAGaming00 / rich-quotes

MIT License
9 stars 3 forks source link

Attempt to find a function Discord has to normaliz... #45

Closed github-actions[bot] closed 3 years ago

github-actions[bot] commented 3 years ago

Attempt to find a function Discord has to normalize embed key's

https://github.com/AAGaming00/rich-quotes/blob/8d565121e04d80abdbfdc2d501cd12c1a8a49d7d/components/Renderer.jsx#L135

            quoteParams.link = link;

            if (this.props.settings.displayEmbeds && (quoteParams.message.embeds?.length !== 0 || quoteParams.message.attachments?.length !== 0)) {
              if (quoteParams.message.embeds?.length !== 0) {
                // @todo Attempt to find a function Discord has to normalize embed key's
                const fixers = [['description','rawDescription'],['title','rawTitle']];

                quoteParams.message.embeds.forEach((e, i) => fixers.forEach((f) => {
                  if (e[f[0]]) {
                    quoteParams.message.embeds[i][f[1]] = e[f[0]];
                    delete quoteParams.message.embeds[i][f[0]];
                  }
                }))
              }

              quoteParams.accessories = renderSimpleAccessories({ message: quoteParams.message, channel: quoteParams.channel}, hasEmbedSpoilers);
            } else quoteParams.accessories = false;
          }
        } else {
          // funni preview handler
ndex 1ba3f97..cbbec60 100644
++ b/index.js

0908efa1f10cfaa7299db0ec2a9e30642de49294