JasonLovesDoggo / JasonLovesDoggo.github.io

My Personal website
http://jasoncameron.dev
MIT License
9 stars 0 forks source link

Integrate Lanyard to have a "current status" widget #54

Open JasonLovesDoggo opened 4 weeks ago

JasonLovesDoggo commented 4 weeks ago

see https://api.lanyard.rest/v1/users/511724576674414600 (my discord id)

JasonLovesDoggo commented 4 weeks ago

Also see https://gist.github.com/dustinrouillard/8140fd47c5900d4421637b098b6d92c0 https://lanyard-visualizer.netlify.app/511724576674414600

JasonLovesDoggo commented 4 weeks ago

These can be fetched through the discord media proxy : https://media.discordapp.net/${activity.assets.large_image.replace("mp:", "")}

or without the discord media proxy if you don't want it, but with it, it keeps the end user's ip hidden from the server hosting the image, since that's not discord for the mp:external assets.

activity.assets.small_image.startsWith('mp:external') ? activity.assets.small_image.replace(/mp:external\/([^\/]*)\/(http[s])/g, '$2:/')
  : https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.small_image}

Of course this is only targeting small_image but you can also use the same for large_image and this section of code will use the external link if external, or the app-assets if it's an app asset