mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-03-21 18:04:10 -05:00
Use updated timestamp from znc as start timestamp and enable timestamp by default
This makes the activity appear in the Active Now panel.
This commit is contained in:
parent
4bc27e3ca9
commit
7ca5b8466d
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user