Skip to content

Commit 51874fd

Browse files
committed
Add support for the new fields in RPC activities
Made possible by discord/discord-api-docs#7674
1 parent 05681d8 commit 51874fd

File tree

6 files changed

+73
-34
lines changed

6 files changed

+73
-34
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Beautify your Discord profile with a customisable Rich Presence, now with custom
3737

3838
1. Download the latest `Source code (zip)` under `Assets` from the [releases page](https://github.com/Jxyme/simple-discord-rpc/releases/latest) on GitHub.
3939

40-
2. Extract `Source code (zip)` to your Desktop, then open the folder: `simple-discord-rpc-2.0.0`.
40+
2. Extract `Source code (zip)` to your Desktop, then open the folder: `simple-discord-rpc-X.X.X`.
4141

4242
3. Open `config.js` in your chosen text editor, and modify the Rich Presence to your liking before saving.
4343

@@ -103,8 +103,10 @@ Countdown to an hour from now (the time will start from the moment you run `simp
103103
assets: {
104104
largeImageKey: 'heart', // asset named 'heart' I uploaded via the Developer Portal
105105
largeImageText: '', // text displayed when hovering over the largeImageKey
106+
largeImageUrl: undefined, // url opened when clicking on the large image
106107
smallImageKey: undefined,
107108
smallImageText: undefined,
109+
smallImageUrl: undefined,
108110
}
109111
}
110112
```
@@ -119,8 +121,10 @@ Countdown to an hour from now (the time will start from the moment you run `simp
119121
assets: {
120122
largeImageKey: 'https://cdn.7tv.app/emote/01F6MQ33FG000FFJ97ZB8MWV52/4x.gif', // catJAM
121123
largeImageText: 'Meow', // text displayed when hovering over the largeImageKey
124+
largeImageUrl: 'https://7tv.app/emotes/01F6MQ33FG000FFJ97ZB8MWV52', // url opened when clicking on the large image
122125
smallImageKey: undefined,
123126
smallImageText: undefined,
127+
smallImageUrl: undefined,
124128
}
125129
}
126130
```
@@ -258,7 +262,9 @@ module.exports = {
258262
applicationId: '1327713183372284027',
259263
activity: {
260264
details: 'Amber Broos',
265+
detailsUrl: undefined,
261266
state: 'Next: NERVO',
267+
stateUrl: undefined,
262268
party: {
263269
partySize: undefined,
264270
partyMax: undefined,
@@ -270,8 +276,10 @@ module.exports = {
270276
assets: {
271277
largeImageKey: 'https://owr-schedule-cdn.tomorrowland.com/1585774431.jpg',
272278
largeImageText: 'Amber Broos',
279+
largeImageUrl: undefined,
273280
smallImageKey: 'https://owr-schedule-cdn.tomorrowland.com/1358567301.jpeg',
274281
smallImageText: 'NERVO',
282+
smallImageUrl: undefined,
275283
},
276284
buttons: {
277285
primary: {
@@ -283,7 +291,8 @@ module.exports = {
283291
url: 'https://www.instagram.com/p/DA6NNcvuOx-',
284292
},
285293
},
286-
type: 3,
294+
type: 3, // Watching: 3
295+
statusDisplayType: 0, // Application Name: 0
287296
},
288297
connection: {
289298
maxRetries: 7,

config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ module.exports = {
99
applicationId: '', // your developer application id
1010
activity: {
1111
details: undefined,
12+
detailsUrl: undefined,
1213
state: undefined,
14+
stateUrl: undefined,
1315
party: {
1416
partySize: undefined,
1517
partyMax: undefined,
@@ -21,8 +23,10 @@ module.exports = {
2123
assets: {
2224
largeImageKey: undefined,
2325
largeImageText: undefined,
26+
largeImageUrl: undefined,
2427
smallImageKey: undefined,
2528
smallImageText: undefined,
29+
smallImageUrl: undefined,
2630
},
2731
buttons: {
2832
primary: {
@@ -35,6 +39,7 @@ module.exports = {
3539
},
3640
},
3741
type: 0, // Playing: 0, Listening to: 2, Watching: 3, or Competing in: 5
42+
statusDisplayType: 0, // Application Name: 0, State: 1, or Details: 2
3843
},
3944
connection: {
4045
maxRetries: 7, // number of retries to establish a connection with Discord (default: 7)

package-lock.json

Lines changed: 33 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"format": "prettier --write ."
1818
},
1919
"dependencies": {
20-
"@xhayper/discord-rpc": "^1.2.0",
20+
"@xhayper/discord-rpc": "^1.3.0",
2121
"joi": "^17.13.3"
2222
},
2323
"devDependencies": {

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,23 @@ const sanitiseActivity = () => {
2525
})
2626
const sanitisedActivity = {
2727
details: activity.details,
28+
detailsUrl: activity.detailsUrl,
2829
state: activity.state,
30+
stateUrl: activity.stateUrl,
2931
partySize: activity.party.partySize,
3032
partyMax: activity.party.partyMax,
3133
startTimestamp: activity.timestamps.startTimestamp,
3234
endTimestamp: activity.timestamps.endTimestamp,
3335
largeImageKey: activity.assets.largeImageKey,
3436
largeImageText: activity.assets.largeImageText,
37+
largeImageUrl: activity.assets.largeImageUrl,
3538
smallImageKey: activity.assets.smallImageKey,
3639
smallImageText: activity.assets.smallImageText,
40+
smallImageUrl: activity.assets.smallImageUrl,
3741
buttons: buttons.length ? buttons : undefined,
3842
instance: false,
3943
type: activity.type,
44+
statusDisplayType: activity.statusDisplayType ?? 0,
4045
}
4146
logger.info(`Attempting to update ${client.user?.username}'s Rich Presence.`)
4247
updateActivity(sanitisedActivity)

src/schemas/ConfigSchema.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ module.exports = Joi.object({
44
applicationId: Joi.string().regex(/^\d+$/).label('Application ID').required(),
55
activity: Joi.object({
66
details: Joi.string().min(2).max(128).label('Details'),
7+
detailsUrl: Joi.string()
8+
.uri({ scheme: ['http', 'https'] })
9+
.max(512)
10+
.label('Details Url'),
711
state: Joi.string().min(2).max(128).label('State'),
12+
stateUrl: Joi.string()
13+
.uri({ scheme: ['http', 'https'] })
14+
.max(512)
15+
.label('State Url'),
816
party: Joi.object({
917
partySize: Joi.number().min(1).label('Party Size'),
1018
partyMax: Joi.number().min(Joi.ref('partySize')).label('Party Max'),
@@ -16,8 +24,16 @@ module.exports = Joi.object({
1624
assets: Joi.object({
1725
largeImageKey: Joi.string().min(1).max(256).label('Large Image Key'),
1826
largeImageText: Joi.string().min(2).max(128).label('Large Image Text'),
27+
largeImageUrl: Joi.string()
28+
.uri({ scheme: ['http', 'https'] })
29+
.max(512)
30+
.label('Large Image Url'),
1931
smallImageKey: Joi.string().min(1).max(256).label('Small Image Key'),
2032
smallImageText: Joi.string().min(2).max(128).label('Small Image Text'),
33+
smallImageUrl: Joi.string()
34+
.uri({ scheme: ['http', 'https'] })
35+
.max(512)
36+
.label('Small Image Url'),
2137
}),
2238
buttons: Joi.object({
2339
primary: Joi.object({
@@ -51,7 +67,8 @@ module.exports = Joi.object({
5167
return value
5268
}),
5369
}),
54-
type: Joi.number().valid(0, 2, 3, 5).label('Type').required(),
70+
type: Joi.number().valid(0, 2, 3, 5).label('Activity Type').required(),
71+
statusDisplayType: Joi.number().valid(0, 1, 2).label('Status Display Type'),
5572
}),
5673
connection: Joi.object({
5774
maxRetries: Joi.number().min(0).label('Maximum Retries').required(),

0 commit comments

Comments
 (0)