fix(memberListActivities): support twitch and attachment images

This commit is contained in:
D3SOX 2024-02-15 13:13:35 +01:00
parent c13bb6e47e
commit 94c5e6fdb7
No known key found for this signature in database
GPG key ID: 39EC1673FC37B048
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,11 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import type { SVGProps } from "react";
export function TwitchIcon(props: SVGProps<SVGSVGElement>) {
return (<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 268" {...props}><path fill="#5a3e85" d="M17.458 0L0 46.556v186.201h63.983v34.934h34.931l34.898-34.934h52.36L256 162.954V0zm23.259 23.263H232.73v128.029l-40.739 40.741H128L93.113 226.92v-34.886H40.717zm64.008 116.405H128V69.844h-23.275zm63.997 0h23.27V69.844h-23.27z"></path></svg>);
}

View file

@ -24,6 +24,7 @@ import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { SpotifyIcon } from "./components/SpotifyIcon"; import { SpotifyIcon } from "./components/SpotifyIcon";
import { TwitchIcon } from "./components/TwitchIcon";
interface Activity { interface Activity {
created_at: number; created_at: number;
@ -58,6 +59,10 @@ export default definePlugin({
icons.push(<SpotifyIcon />); icons.push(<SpotifyIcon />);
} }
if (activities.some(activity => activity.name === "Twitch")) {
icons.push(<TwitchIcon />);
}
const applications = activities.filter(activity => activity.application_id); const applications = activities.filter(activity => activity.application_id);
applications.forEach(activity => { applications.forEach(activity => {
const { assets } = activity; const { assets } = activity;
@ -71,6 +76,12 @@ export default definePlugin({
if (externalLink) { if (externalLink) {
icons.push(<img src={externalDiscordLink} alt={alt}/>); icons.push(<img src={externalDiscordLink} alt={alt}/>);
} }
} else if (image.startsWith("mp:attachments/")) {
const attachmentId = image.replace(/mp:attachments\//, "");
const attachmentLink = `https://media.discordapp.net/attachments/${attachmentId}`;
if (attachmentId) {
icons.push(<img src={attachmentLink} alt={alt}/>);
}
} else { } else {
const src = `https://cdn.discordapp.com/app-assets/${activity.application_id}/${image}.png`; const src = `https://cdn.discordapp.com/app-assets/${activity.application_id}/${image}.png`;
icons.push(<img src={src} alt={alt}/>); icons.push(<img src={src} alt={alt}/>);