From 40bd671ce21b76ea4d6a73373ea545764e6400bb Mon Sep 17 00:00:00 2001 From: Luna Date: Thu, 19 Aug 2021 20:33:57 +0200 Subject: [PATCH 1/2] allow activity types (fixes #146) --- src/client.js | 7 ++++++- src/constants.js | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 0ff29da..2624d3d 100644 --- a/src/client.js +++ b/src/client.js @@ -4,7 +4,7 @@ const EventEmitter = require('events'); const { setTimeout, clearTimeout } = require('timers'); const fetch = require('node-fetch'); const transports = require('./transports'); -const { RPCCommands, RPCEvents, RelationshipTypes } = require('./constants'); +const { RPCCommands, RPCEvents, RelationshipTypes, ActivityTypes } = require('./constants'); const { pid: getPid, uuid } = require('./util'); function subKey(event, args) { @@ -472,6 +472,7 @@ class RPCClient extends EventEmitter { let assets; let party; let secrets; + let type = ActivityTypes.PLAYING; if (args.startTimestamp || args.endTimestamp) { timestamps = { start: args.startTimestamp, @@ -514,11 +515,15 @@ class RPCClient extends EventEmitter { spectate: args.spectateSecret, }; } + if (args.type) { + type = args.type; + } return this.request(RPCCommands.SET_ACTIVITY, { pid, activity: { state: args.state, + type: type, details: args.details, timestamps, assets, diff --git a/src/constants.js b/src/constants.js index 441f832..41a57ca 100644 --- a/src/constants.js +++ b/src/constants.js @@ -176,3 +176,12 @@ exports.RelationshipTypes = { PENDING_OUTGOING: 4, IMPLICIT: 5, }; + +exports.ActivityTypes = { + PLAYING: 0, + STREAMING: 1, + LISTENING: 2, + WATCHING: 3, + CUSTOM: 4, + COMPETING: 5 +} From 1c5b6842fa586a1b7b339a50fa5ec1c4cf6c8867 Mon Sep 17 00:00:00 2001 From: sKiLdUsT Date: Fri, 2 Aug 2024 03:57:16 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: advaith --- src/client.js | 2 +- src/constants.js | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/client.js b/src/client.js index 2624d3d..d5ab445 100644 --- a/src/client.js +++ b/src/client.js @@ -523,7 +523,7 @@ class RPCClient extends EventEmitter { pid, activity: { state: args.state, - type: type, + type, details: args.details, timestamps, assets, diff --git a/src/constants.js b/src/constants.js index 41a57ca..f1c06ce 100644 --- a/src/constants.js +++ b/src/constants.js @@ -178,10 +178,8 @@ exports.RelationshipTypes = { }; exports.ActivityTypes = { - PLAYING: 0, - STREAMING: 1, - LISTENING: 2, - WATCHING: 3, - CUSTOM: 4, - COMPETING: 5 + PLAYING: 0, + LISTENING: 2, + WATCHING: 3, + COMPETING: 5, }