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
Size: 751
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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 });