Show Splatoon 3 presence data in nxapi util discord-activity when using a presence URL

This commit is contained in:
Samuel Elliott 2022-10-28 02:21:40 +01:00
parent e8cbbd39ca
commit 30418d89b6
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 6 additions and 4 deletions

View File

@ -90,7 +90,7 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
readonly [Presence, CurrentUser | Friend | undefined, unknown] :
await getPresenceFromCoral(argv);
const discordpresence = getActivityFromPresence(argv, presence, user, friendcode, activeevent);
const discordpresence = getActivityFromPresence(argv, presence, user, friendcode, activeevent, response);
const application = argv.showDiscordApplication ?
discordpresence ? await getDiscordApplicationRpc(discordpresence.id) : null : undefined;
@ -175,6 +175,7 @@ function getActivityFromPresence(
user?: CurrentUser | Friend,
friendcode?: CurrentUser['links']['friendCode'],
activeevent?: ActiveEvent,
proxy_response?: unknown,
) {
const online = presence?.state === PresenceState.ONLINE || presence?.state === PresenceState.PLAYING;
@ -203,6 +204,7 @@ function getActivityFromPresence(
activeevent,
show_play_time,
// znc_discord_presence: this,
proxy_response,
nsaid: argv.friendNsaid ?? user?.nsaId,
user,
};

View File

@ -94,6 +94,7 @@ class ZncDiscordPresenceClient {
activeevent: this.m.show_active_event ? activeevent : undefined,
show_play_time: this.m.show_play_time,
znc_discord_presence: this.m,
proxy_response: (this.m) instanceof ZncProxyDiscordPresence ? this.m.last_data : undefined,
monitors: [...this.monitors.values()],
nsaid: this.m.presence_user!,
user,

View File

@ -232,9 +232,7 @@ interface PresenceUrlResponse {
export function callback(activity: DiscordRPC.Presence, game: Game, context?: DiscordPresenceContext) {
const monitor = context?.monitors?.find(m => m instanceof SplatNet3Monitor) as SplatNet3Monitor | undefined;
const presence_proxy_data =
context?.znc_discord_presence instanceof ZncProxyDiscordPresence ?
context.znc_discord_presence.last_data as PresenceUrlResponse : null;
const presence_proxy_data = context?.proxy_response ? context.proxy_response as PresenceUrlResponse : null;
const friend = presence_proxy_data?.splatoon3 ?? monitor?.friend;
const fest = presence_proxy_data?.splatoon3_fest ?? monitor?.fest;

View File

@ -8,6 +8,7 @@ export interface DiscordPresenceContext {
activeevent?: ActiveEvent;
show_play_time?: DiscordPresencePlayTime;
znc_discord_presence?: ZncDiscordPresence | ZncProxyDiscordPresence;
proxy_response?: unknown;
monitors?: ExternalMonitor[];
nsaid?: string;
user?: CurrentUser | Friend;