Update to use new ID system

This commit is contained in:
bingus_violet 2024-10-16 01:27:53 -05:00
parent 68108e78ab
commit 08efae73bd

View file

@ -3,32 +3,6 @@ const path = require("path"),
var constants = JSON.parse(fs.readFileSync(path.join(__dirname, 'constants.json'))) var constants = JSON.parse(fs.readFileSync(path.join(__dirname, 'constants.json')))
function get_img_url(activity, size = "large_image") {
if ("assets" in activity) {
var image = activity.assets[size]
if (image) {
if (image.includes("mp:external")) {
return ('https://media.discordapp.net/external' + image.substr(image.indexOf('mp:external') + 11, image.length))
} else if (image.includes("https/")) {
return decodeURIComponent('https://' + image.substr(image.indexOf('https/') + 6, image.length))
} else if (image.includes("spotify")) {
return decodeURIComponent('https://i.scdn.co/image/' + image.substr(image.indexOf('spotify:') + 8, image.length))
} else {
return decodeURIComponent('https://cdn.discordapp.com/app-assets/' + activity.application_id + "/" + image + ".png")
}
}
}
if (!image && size == "large_image") {
if (activity.name in activityImages) {
return decodeURIComponent(activityImages[activity.name])
}
}
return null
}
function makeCompat(string="") { function makeCompat(string="") {
return string.replaceAll("<", "&lt;").replaceAll(">", "&gt;") return string.replaceAll("<", "&lt;").replaceAll(">", "&gt;")
} }
@ -89,7 +63,7 @@ module.exports = {
} }
function get_img(activity, size = "large_image") { function get_img(activity, size = "large_image") {
return "https://cache.violets-purgatory.dev/cached/" + get_img_url(activity, size) return "https://cache.violets-purgatory.dev/cached/byID/" + activity.id + "?size=" + size
} }
function activityTime() { function activityTime() {