Package and Activity Status Update
This commit is contained in:
@@ -11,12 +11,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-node": "^5.4.0",
|
||||
"@sveltejs/kit": "^2.49.0",
|
||||
"@sveltejs/kit": "^2.49.1",
|
||||
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
||||
"@tailwindcss/forms": "^0.5.10",
|
||||
"@tailwindcss/typography": "^0.5.19",
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
"svelte": "^5.45.2",
|
||||
"svelte": "^5.45.6",
|
||||
"svelte-check": "^4.3.4",
|
||||
"tailwindcss": "^4.1.17",
|
||||
"typescript": "^5.9.3",
|
||||
@@ -24,12 +24,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@iconify/svelte": "^5.1.0",
|
||||
"@threlte/core": "^8.3.0",
|
||||
"@threlte/core": "^8.3.1",
|
||||
"@types/three": "^0.181.0",
|
||||
"cors": "^2.8.5",
|
||||
"discord.js": "^14.25.1",
|
||||
"dotenv": "^17.2.3",
|
||||
"express": "^5.1.0",
|
||||
"express": "^5.2.1",
|
||||
"hotkeys-js": "^4.0.0-beta.7",
|
||||
"play-dl": "^1.9.7",
|
||||
"three": "^0.181.2"
|
||||
|
||||
@@ -332,10 +332,10 @@
|
||||
<div class="activity-card">
|
||||
<div class="activity-type-label">{getActivityTypeLabel(activity.type)}</div>
|
||||
<div class="activity-content">
|
||||
{#if activity.assets?.large_image}
|
||||
{#if activity.assets?.large_image || activity.app_icon}
|
||||
<div class="activity-images">
|
||||
<img
|
||||
src={activity.assets.large_image}
|
||||
src={activity.assets?.large_image ?? activity.app_icon}
|
||||
alt=""
|
||||
class="activity-large-image"
|
||||
/>
|
||||
|
||||
@@ -15,6 +15,7 @@ export type Activity = {
|
||||
application_id?: string | null;
|
||||
assets?: { large_image?: string | null; small_image?: string | null };
|
||||
emoji?: { id?: string; animated?: boolean } | null;
|
||||
app_icon?: string | null;
|
||||
};
|
||||
|
||||
export type Data = {
|
||||
@@ -114,6 +115,8 @@ export async function fetchUserImages(data: Data, settings: ProfileSettings) {
|
||||
ImageSize.ACTIVITY_LARGE,
|
||||
settings.theme || null
|
||||
);
|
||||
else if (activity?.app_icon)
|
||||
assetLargeImage = await encodeBase64(activity.app_icon, ImageSize.ACTIVITY_LARGE);
|
||||
|
||||
if (activity?.assets?.small_image)
|
||||
assetSmallImage = await encodeBase64(
|
||||
|
||||
@@ -6,7 +6,7 @@ class Bot {
|
||||
private client: Client;
|
||||
|
||||
// Normalize a discord.js Activity object into a simple POJO
|
||||
private mapActivity(a: any) {
|
||||
private async mapActivity(a: any) {
|
||||
const type = typeof a.type === 'number' ? a.type : (ActivityType[a.type] ?? a.type);
|
||||
const application_id = a.applicationId ?? a.application_id ?? null;
|
||||
|
||||
@@ -23,6 +23,17 @@ class Bot {
|
||||
return raw;
|
||||
};
|
||||
|
||||
let app_icon = null;
|
||||
if (type === 0 && application_id) {
|
||||
try {
|
||||
const appUser = await this.client.users.fetch(application_id);
|
||||
app_icon = appUser.displayAvatarURL({ extension: 'webp', size: 128 });
|
||||
} catch (e) {
|
||||
// Placeholder for apps that don't have a bot user
|
||||
app_icon = "https://cdn.discordapp.com/embed/avatars/0.png";
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
name: a.name ?? null,
|
||||
type,
|
||||
@@ -33,6 +44,7 @@ class Bot {
|
||||
large_image: formatAsset(rawLarge),
|
||||
small_image: formatAsset(rawSmall)
|
||||
},
|
||||
app_icon,
|
||||
emoji: a.emoji ? { id: a.emoji.id ?? null, animated: !!a.emoji.animated } : null
|
||||
};
|
||||
}
|
||||
@@ -91,7 +103,7 @@ class Bot {
|
||||
if (!presence) return { guildId, status: 'offline', activities: [], displayName: member.displayName, avatarUrl, guildTag, guildTagBadgeImage };
|
||||
|
||||
const status = presence.status;
|
||||
const activities = (presence.activities || []).map((a: any) => this.mapActivity(a));
|
||||
const activities = await Promise.all((presence.activities || []).map(async (a: any) => await this.mapActivity(a)));
|
||||
|
||||
return { guildId, status, activities, displayName: member.displayName, avatarUrl, guildTag, guildTagBadgeImage };
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user