Skip to content

Commit f921519

Browse files
committed
add urls and status display type to presence
1 parent 6eb54af commit f921519

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/plugins/discord/discord-service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Client as DiscordClient } from '@xhayper/discord-rpc';
1+
import {
2+
Client as DiscordClient,
3+
StatusDisplayType,
4+
} from '@xhayper/discord-rpc';
25
import { dev } from 'electron-is';
36
import { ActivityType } from 'discord-api-types/v10';
47

@@ -98,8 +101,11 @@ export class DiscordService {
98101

99102
const activityInfo: SetActivity = {
100103
type: ActivityType.Listening,
104+
statusDisplayType: StatusDisplayType.STATE,
101105
details: truncateString(songInfo.title, 128), // Song title
106+
detailsUrl: songInfo.url,
102107
state: truncateString(songInfo.artist, 128), // Artist name
108+
stateUrl: songInfo.artistUrl,
103109
largeImageKey: songInfo.imageSrc ?? undefined,
104110
largeImageText: songInfo.album
105111
? truncateString(songInfo.album, 128)
@@ -109,7 +115,7 @@ export class DiscordService {
109115

110116
// Handle paused state display
111117
if (songInfo.isPaused) {
112-
activityInfo.largeImageText = '⏸';
118+
activityInfo.largeImageText = '⏸';
113119
} else if (
114120
!config.hideDurationLeft &&
115121
songInfo.songDuration > 0 &&

src/providers/song-info.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface SongInfo {
3030
title: string;
3131
alternativeTitle?: string;
3232
artist: string;
33+
artistUrl?: string;
3334
views: number;
3435
uploadDate?: string;
3536
imageSrc?: string | null;
@@ -72,6 +73,7 @@ const handleData = async (
7273
title: '',
7374
alternativeTitle: '',
7475
artist: '',
76+
artistUrl: '',
7577
views: 0,
7678
uploadDate: '',
7779
imageSrc: '',
@@ -93,6 +95,7 @@ const handleData = async (
9395
songInfo.url = microformat.urlCanonical?.split('&')[0];
9496
songInfo.playlistId =
9597
new URL(microformat.urlCanonical).searchParams.get('list') ?? '';
98+
songInfo.artistUrl = microformat.pageOwnerDetails.youtubeProfileUrl;
9699
// Used for options.resumeOnStart
97100
config.set('url', microformat.urlCanonical);
98101
songInfo.alternativeTitle = microformat.linkAlternates.find(
@@ -110,7 +113,7 @@ const handleData = async (
110113
songInfo.elapsedSeconds = videoDetails.elapsedSeconds;
111114
songInfo.isPaused = videoDetails.isPaused;
112115
songInfo.videoId = videoDetails.videoId;
113-
songInfo.album = data?.videoDetails?.album; // Will be undefined if video exist
116+
songInfo.album = videoDetails.album; // Will be undefined if video exist
114117

115118
switch (videoDetails?.musicVideoType) {
116119
case 'MUSIC_VIDEO_TYPE_ATV':

0 commit comments

Comments
 (0)