discord-rpc-revamp
v2.0.4
Published
Note: This package is a revamp of [@discordjs/rpc](https://npmjs.com/package/discord-rpc), because I felt like it didn't work very well - so I rewrote it.
Downloads
107
Readme
Discord RPC Revamp
Note: This package is a revamp of @discordjs/rpc, because I felt like it didn't work very well - so I rewrote it.
The code is messy, but here are some useful tips:
- The API is the same as in @discordjs/rpc, except
login()
is nowconnect()
and does not take a client secret. - Calling
subscribe()
will subscribe the client instance to the event, to handle it useclient.on('EVENT', function handler() {})
- List of events, methods, general guide on RPC (outdated but mostly relevant): link
Example
let client = new (require('discord-rpc-revamp').Client)();
client.connect({ clientId: 'YOUR_CLIENT_ID_HERE' }).catch(console.error);
client.on('ready', _ => {
client.setActivity({
details: 'Discord Rich Presence',
state: 'Hello there!',
startTimestamp: Date.now()
}).then(_ => console.log('set activity')).catch(console.error);
client.subscribe('ACTIVITY_JOIN');
client.subscribe('ACTIVITY_JOIN_REQUEST');
client.on('ACTIVITY_JOIN', data => {
console.log('ACTIVITY_JOIN', data);
});
});
Enjoy!