diff --git a/src/common/presence.ts b/src/common/presence.ts index 5040b3f..a624e57 100644 --- a/src/common/presence.ts +++ b/src/common/presence.ts @@ -137,7 +137,13 @@ export class ZncDiscordPresence extends ZncNotifications { if (discordpresence.title) { if (discordpresence.title !== this.title?.id) { - this.title = {id: discordpresence.title, since: Date.now()}; + // Use the timestamp the user's presence was last updated according to Nintendo + // This may be incorrect as this will also change when the state/description changes in the + // same title, but this shouldn't matter unless the process is restarted or presence tracking + // is reset for some other reason (e.g. using the Electron app) + const since = Math.min(presence.updatedAt * 1000, Date.now()); + + this.title = {id: discordpresence.title, since}; } if (discordpresence.showTimestamp) { diff --git a/src/discord/titles/nintendo.ts b/src/discord/titles/nintendo.ts index 4ba581c..ba57501 100644 --- a/src/discord/titles/nintendo.ts +++ b/src/discord/titles/nintendo.ts @@ -23,12 +23,33 @@ export const titles: Title[] = [ showActiveEvent: true, }, { - // Splatoon 2: Splatfest World Premiere [Europe, The Americas] + // Splatoon 2 Global Testfire [The Americas] + id: '010000a00218e000', + client: '950886725398429726', + largeImageText: 'Global Testfire', + showPlayingOnline: true, + }, + { + // Splatoon 2: Splatfest World Premiere [Europe] + id: '010086f0040fc000', + client: '950886725398429726', + largeImageText: 'Splatfest World Premiere', + showPlayingOnline: true, + }, + { + // Splatoon 2: Splatfest World Premiere [The Americas] id: '01003870040fa000', client: '950886725398429726', largeImageText: 'Splatfest World Premiere', showPlayingOnline: true, }, + { + // Splatoon 2: Splatfest World Premiere [Japan] ??? + id: '0100d070040f8000', + client: '950886725398429726', + largeImageText: 'Splatfest World Premiere', + showPlayingOnline: true, + }, { // Splatoon 2: Special Demo [Europe] id: '01007e200d45c000', diff --git a/src/discord/util.ts b/src/discord/util.ts index 881e9df..954b53d 100644 --- a/src/discord/util.ts +++ b/src/discord/util.ts @@ -13,7 +13,7 @@ export function getDiscordPresence( const titleid = getTitleIdFromEcUrl(game.shopUri); const title = titles.find(t => t.id === titleid) || defaultTitle; - const text = []; + const text: (string | undefined)[] = []; if (title.titleName === true) text.push(game.name); else if (title.titleName) text.push(title.titleName); @@ -28,6 +28,10 @@ export function getDiscordPresence( else if (online && title.showPlayingOnline === true) text.push('Playing online' + event_text); else if (online && title.showPlayingOnline) text.push(title.showPlayingOnline as string + event_text); + // Always show play time as `state`, not `details` + // This doesn't normally have a noticeable effect, but the Active Now panel does show details/state differently + if (!text.length) text.push(undefined); + if ((title.showPlayTime ?? true) && game.totalPlayTime >= 60) { const play_time_text = getPlayTimeText(context?.show_play_time ?? DiscordPresencePlayTime.DETAILED_PLAY_TIME_SINCE, game); @@ -63,7 +67,7 @@ export function getDiscordPresence( id: title.client || defaultTitle.client, title: titleid, activity, - showTimestamp: title.showTimestamp, + showTimestamp: title.showTimestamp ?? true, }; } @@ -199,9 +203,13 @@ export interface Title { smallImageKey?: string; smallImageText?: string; /** - * Whether to show the timestamp the user started playing the title in Discord. Discord shows this as the number of minutes and seconds since the timestamp; this will be inaccurate as it may take up to a minute (by default) to detect the user's presence, so this is disabled by default. + * Whether to show the timestamp the user started playing the title in Discord. Discord shows this as the number of minutes and seconds since the timestamp. * - * @default false + * If enabled this is set to the time the user's presence was last updated as reported by Nintendo. Any changes to the updated timestamp will be ignored as long as the title doesn't change. The timestamp may change if the presence tracking is reset for any reason. + * + * This is now enabled by default as it's required for the activity to show in the Active Now panel. + * + * @default true */ showTimestamp?: boolean; /**