Discord RPC Client
Official RPC extension for Discord.js, and all types used in this library are from Discord.js
Browser Example
const { Client } = require('discord-rpc');
const clientID = '187406016902594560';
const scopes = ['rpc', 'rpc.api', 'messages.read'];
const params = new URLSearchParams(document.location.hash.slice(1));
if (!params.has('access_token')) {
document.location.href =
`https://discordapp.com/oauth2/authorize?response_type=token&client_id=${clientID}&scope=${scopes.join('%20')}`;
}
const client = new Client({ transport: 'websocket' });
client.on('ready', () => {
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.tag);
});
client.login(clientID, { accessToken: params.get('access_token'), scopes });