File tree Expand file tree Collapse file tree 5 files changed +47
-1
lines changed Expand file tree Collapse file tree 5 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 437437 "hide-duration-left" : " Hide duration left" ,
438438 "hide-github-button" : " Hide GitHub link Button" ,
439439 "play-on-youtube-music" : " Play on YouTube Music" ,
440- "set-inactivity-timeout" : " Set inactivity timeout"
440+ "set-inactivity-timeout" : " Set inactivity timeout" ,
441+ "set-status-display-type" : {
442+ "label" : " Status text" ,
443+ "submenu" : {
444+ "youtube-music" : " Listening to YouTube Music" ,
445+ "artist" : " Listening to {artist}" ,
446+ "title" : " Listening to {song title}"
447+ }
448+ }
441449 },
442450 "name" : " Discord Rich Presence" ,
443451 "prompt" : {
Original file line number Diff line number Diff line change @@ -23,3 +23,13 @@ export enum TimerKey {
2323 UpdateTimeout = 'updateTimeout' , // Timer for throttled activity updates
2424 DiscordConnectRetry = 'discordConnectRetry' , // Timer for Discord connection retries
2525}
26+
27+ /**
28+ * An enum for Discord's activity.status_display_type field, governing which field of the activity should be used after
29+ * "Listening to..." in the user's Discord status.
30+ */
31+ export const DiscordStatusDisplayType = {
32+ YOUTUBE_MUSIC : 0 ,
33+ ARTIST : 1 ,
34+ TITLE : 2 ,
35+ } as const ;
Original file line number Diff line number Diff line change @@ -98,7 +98,9 @@ export class DiscordService {
9898
9999 const activityInfo : SetActivity = {
100100 type : ActivityType . Listening ,
101+ statusDisplayType : config . statusDisplayType ,
101102 details : truncateString ( songInfo . title , 128 ) , // Song title
103+ detailsUrl : songInfo . url ?? undefined ,
102104 state : truncateString ( songInfo . artist , 128 ) , // Artist name
103105 largeImageKey : songInfo . imageSrc ?? undefined ,
104106 largeImageText : songInfo . album
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { createPlugin } from '@/utils';
22import { backend } from './main' ;
33import { onMenu } from './menu' ;
44import { t } from '@/i18n' ;
5+ import { DiscordStatusDisplayType } from './constants' ;
56
67export type DiscordPluginConfig = {
78 enabled : boolean ;
@@ -33,6 +34,10 @@ export type DiscordPluginConfig = {
3334 * Hide the "duration left" in the rich presence
3435 */
3536 hideDurationLeft : boolean ;
37+ /**
38+ * Hide the "duration left" in the rich presence
39+ */
40+ statusDisplayType : ( typeof DiscordStatusDisplayType ) [ keyof typeof DiscordStatusDisplayType ] ;
3641} ;
3742
3843export default createPlugin ( {
@@ -47,6 +52,7 @@ export default createPlugin({
4752 playOnYouTubeMusic : true ,
4853 hideGitHubButton : false ,
4954 hideDurationLeft : false ,
55+ statusDisplayType : DiscordStatusDisplayType . ARTIST ,
5056 } as DiscordPluginConfig ,
5157 menu : onMenu ,
5258 backend,
Original file line number Diff line number Diff line change @@ -12,11 +12,18 @@ import type { MenuContext } from '@/types/contexts';
1212import type { DiscordPluginConfig } from './index' ;
1313
1414import type { MenuTemplate } from '@/menu' ;
15+ import { DiscordStatusDisplayType } from './constants' ;
1516
1617const registerRefreshOnce = singleton ( ( refreshMenu : ( ) => void ) => {
1718 discordService ?. registerRefreshCallback ( refreshMenu ) ;
1819} ) ;
1920
21+ const DiscordStatusDisplayTypeLabels = {
22+ [ DiscordStatusDisplayType . YOUTUBE_MUSIC ] : "plugins.discord.menu.set-status-display-type.submenu.youtube-music" ,
23+ [ DiscordStatusDisplayType . ARTIST ] : "plugins.discord.menu.set-status-display-type.submenu.artist" ,
24+ [ DiscordStatusDisplayType . TITLE ] : "plugins.discord.menu.set-status-display-type.submenu.title" ,
25+ }
26+
2027export const onMenu = async ( {
2128 window,
2229 getConfig,
@@ -92,6 +99,19 @@ export const onMenu = async ({
9299 label : t ( 'plugins.discord.menu.set-inactivity-timeout' ) ,
93100 click : ( ) => setInactivityTimeout ( window , config ) ,
94101 } ,
102+ {
103+ label : t ( 'plugins.discord.menu.set-status-display-type.label' ) ,
104+ submenu : Object . values ( DiscordStatusDisplayType ) . map ( ( statusDisplayType ) => ( {
105+ label : t ( DiscordStatusDisplayTypeLabels [ statusDisplayType ] ) ,
106+ type : 'radio' ,
107+ checked : config . statusDisplayType == statusDisplayType ,
108+ click ( ) {
109+ setConfig ( {
110+ statusDisplayType
111+ } ) ;
112+ } ,
113+ } ) ) ,
114+ } ,
95115 ] ;
96116} ;
97117
You can’t perform that action at this time.
0 commit comments