discordjs/RPC

Name: RPC

Owner: Discord.js

Description: A simple RPC client for Discord

Created: 2016-11-17 04:59:07.0

Updated: 2018-01-18 21:34:45.0

Pushed: 2018-01-20 02:02:07.0

Homepage:

Size: 751

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README


Discord server NPM version NPM downloads Dependencies Patreon

NPM info

Discord.js RPC Extension

Documentation
Rich Presence Example
Browser Example
t { Client } = require('discord-rpc/browser');

t clientID = '187406016902594560';
t scopes = ['rpc', 'rpc.api', 'messages.read'];

his demonstrates discord's implicit oauth2 flow
ttp://discordapi.com/topics/oauth2#implicit-grant

t params = new URLSearchParams(document.location.hash.slice(1));

t accessToken = params.has('access_token') ?
rams.get('access_token') : localStorage.accessToken;
lStorage.accessToken = accessToken;

!accessToken) {
 Redirect to discord to get an access token
cument.location.href = `https://discordapp.com/oauth2/authorize?response_type=token&client_id=${clientID}&scope=${scopes.join(' ')}`;


t client = new Client({ transport: 'websocket' });

nt.on('ready', () => {
nsole.log('Logged in as', client.application.name);
nsole.log('Authed for user', client.user.tag);

ient.selectVoiceChannel('81384788862181376');


og in to RPC with client id and access token
nt.login(clientID, { accessToken, scopes });

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.