add streaming button, fix twitch icon
All checks were successful
Code quality checks / biome (push) Successful in 9s
All checks were successful
Code quality checks / biome (push) Successful in 9s
This commit is contained in:
parent
af872d538c
commit
076f886e79
1 changed files with 35 additions and 25 deletions
|
@ -111,6 +111,11 @@ function resolveActivityImage(img, applicationId) {
|
||||||
return `https://i.scdn.co/image/${img.split(":")[1]}`;
|
return `https://i.scdn.co/image/${img.split(":")[1]}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (img.startsWith("twitch:")) {
|
||||||
|
const username = img.split(":")[1];
|
||||||
|
return `https://static-cdn.jtvnw.net/previews-ttv/live_user_${username}-440x248.jpg`;
|
||||||
|
}
|
||||||
|
|
||||||
return `https://cdn.discordapp.com/app-assets/${applicationId}/${img}.png`;
|
return `https://cdn.discordapp.com/app-assets/${applicationId}/${img}.png`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,10 +171,7 @@ function buildActivityHTML(activity) {
|
||||||
</div>`
|
</div>`
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
const activityButtons =
|
const buttons = (activity.buttons || [])
|
||||||
(activity.buttons && activity.buttons.length > 0
|
|
||||||
? `<div class="activity-buttons">
|
|
||||||
${activity.buttons
|
|
||||||
.map((button, index) => {
|
.map((button, index) => {
|
||||||
const label = typeof button === "string" ? button : button.label;
|
const label = typeof button === "string" ? button : button.label;
|
||||||
let url = null;
|
let url = null;
|
||||||
|
@ -182,15 +184,23 @@ function buildActivityHTML(activity) {
|
||||||
? `<a href="${url}" class="activity-button" target="_blank" rel="noopener noreferrer">${label}</a>`
|
? `<a href="${url}" class="activity-button" target="_blank" rel="noopener noreferrer">${label}</a>`
|
||||||
: null;
|
: null;
|
||||||
})
|
})
|
||||||
.filter(Boolean)
|
.filter(Boolean);
|
||||||
.join("")}
|
|
||||||
</div>`
|
if (!buttons.length && activity.name === "Twitch" && activity.url) {
|
||||||
: "") +
|
buttons.push(
|
||||||
(activity.name === "Spotify" && activity.sync_id
|
`<a href="${activity.url}" class="activity-button" target="_blank" rel="noopener noreferrer">Watch on Twitch</a>`,
|
||||||
? `<div class="activity-buttons">
|
);
|
||||||
<a href="https://open.spotify.com/track/${activity.sync_id}" class="activity-button" target="_blank" rel="noopener noreferrer">Listen on Spotify</a>
|
}
|
||||||
</div>`
|
|
||||||
: "");
|
if (activity.name === "Spotify" && activity.sync_id) {
|
||||||
|
buttons.push(
|
||||||
|
`<a href="https://open.spotify.com/track/${activity.sync_id}" class="activity-button" target="_blank" rel="noopener noreferrer">Listen on Spotify</a>`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const activityButtons = buttons.length
|
||||||
|
? `<div class="activity-buttons">${buttons.join("")}</div>`
|
||||||
|
: "";
|
||||||
|
|
||||||
const progressBar =
|
const progressBar =
|
||||||
progress !== null
|
progress !== null
|
||||||
|
|
Loading…
Add table
Reference in a new issue