Skip to content

Commit

Permalink
allow activity types (fixes discordjs#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna committed Aug 19, 2021
1 parent 6f83d8d commit 40bd671
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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
}

0 comments on commit 40bd671

Please sign in to comment.