Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow activity types #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Comment on lines +180 to +187
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exports.ActivityTypes = {
PLAYING: 0,
STREAMING: 1,
LISTENING: 2,
WATCHING: 3,
CUSTOM: 4,
COMPETING: 5
}
exports.ActivityTypes = {
PLAYING: 0,
WATCHING: 3
}

Only PLAYING and WATCHING are allowed by RPC. Everything else results in an error.