mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 18:13:31 +00:00
[enhancement]: use discord activity type listening
This commit is contained in:
parent
271be93a96
commit
284db988c9
3 changed files with 197 additions and 21 deletions
|
|
@ -25,23 +25,27 @@ export const useDiscordRpc = () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const song = currentSong?.id ? currentSong : null;
|
||||
|
||||
const currentTime = usePlayerStore.getState().current.time;
|
||||
|
||||
const now = Date.now();
|
||||
const start = currentTime ? Math.round(now - currentTime * 1000) : null;
|
||||
const end =
|
||||
currentSong?.duration && start ? Math.round(start + currentSong.duration) : null;
|
||||
const end = song?.duration && start ? Math.round(start + song.duration) : null;
|
||||
|
||||
const artists = currentSong?.artists.map((artist) => artist.name).join(', ');
|
||||
const artists = song?.artists.map((artist) => artist.name).join(', ');
|
||||
|
||||
const activity: SetActivity = {
|
||||
details: currentSong?.name.padEnd(2, ' ') || 'Idle',
|
||||
details: song?.name.padEnd(2, ' ') || 'Idle',
|
||||
instance: false,
|
||||
largeImageKey: undefined,
|
||||
largeImageText: currentSong?.album || 'Unknown album',
|
||||
largeImageText: song?.album || 'Unknown album',
|
||||
smallImageKey: undefined,
|
||||
smallImageText: currentStatus,
|
||||
state: (artists && `By ${artists}`) || 'Unknown artist',
|
||||
// I would love to use the actual type as opposed to hardcoding to 2,
|
||||
// but manually installing the discord-types package appears to break things
|
||||
type: 2,
|
||||
};
|
||||
|
||||
if (currentStatus === PlayerStatus.PLAYING) {
|
||||
|
|
@ -56,11 +60,11 @@ export const useDiscordRpc = () => {
|
|||
}
|
||||
|
||||
if (
|
||||
currentSong?.serverType === ServerType.JELLYFIN &&
|
||||
song?.serverType === ServerType.JELLYFIN &&
|
||||
discordSettings.showServerImage &&
|
||||
currentSong?.imageUrl
|
||||
song?.imageUrl
|
||||
) {
|
||||
activity.largeImageKey = currentSong?.imageUrl;
|
||||
activity.largeImageKey = song?.imageUrl;
|
||||
}
|
||||
|
||||
// Fall back to default icon if not set
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue