Git Product home page Git Product logo

rpc's People

Contributors

davidcralph avatar devsnek avatar dhleong avatar dscalzi avatar ewang2002 avatar framerate avatar goddere2d avatar greenkeeper[bot] avatar icrawl avatar mattipv4 avatar plasmachicken avatar seldszar avatar shizmob avatar snazzah avatar spdermn02 avatar urusai88 avatar uwx avatar vaporoxx avatar vladshcherbin avatar zlyfer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpc's Issues

IPC transport is broken

I'm trying to use the DiscordJS RPC as a userscript with Tampermonkey (original issue which redirect me to this repo here). I am unable to use the IPC transport (since websocket is in private beta according to Discord docs).

Here is the sample code I'm trying to make it work on Chrome v66.0.3359.139:

	// I require DiscordJS/RPC from JSDelivr:
	// https://cdn.jsdelivr.net/npm/[email protected]/browser.min.js

    const clientID = 'my-client-id';
    const accessToken = 'my-access-token';
    const scopes = ['rpc', 'rpc.api'];

    const client = new DiscordRPC.Client({ transport: 'ipc' });

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

    client.login(clientID, { accessToken, scopes });

Here is the error I have:

	TypeError: t is not a constructor
	    at new e.exports (userscript.html?id=49e3d5d8-3aeb-40a2-96dc-0270cf660ee9:8)
	    at eval (userscript.html?id=49e3d5d8-3aeb-40a2-96dc-0270cf660ee9:30)
	    at Window.eval (userscript.html?id=49e3d5d8-3aeb-40a2-96dc-0270cf660ee9:40)
	    at <anonymous>:2:120
	    at eval (userscript.html?id=49e3d5d8-3aeb-40a2-96dc-0270cf660ee9:2)
	    at eval (userscript.html?id=49e3d5d8-3aeb-40a2-96dc-0270cf660ee9:3)
	    at Object.eval (userscript.html?id=49e3d5d8-3aeb-40a2-96dc-0270cf660ee9:41)
	    at eval (userscript.html?id=49e3d5d8-3aeb-40a2-96dc-0270cf660ee9:43)
	    at eval (<anonymous>)
	    at <anonymous>:2:120

which points to this source-code (no source-map in production, can't really help on the debugging):

constructor(e={}) {
    super(Object.assign({
        _tokenType: "Bearer"
    }, e)),
    this.accessToken = null,
    this.clientID = null,
    this.application = null,
    this.user = null;
    const t = o[e.transport];
    if (!t)
        throw new T("RPC_INVALID_TRANSPORT",e.transport);
    this.transport = new t(this),
    this.transport.on("message", this._onRpcMessage.bind(this)),
    this._expecting = new Map,
    this._subscriptions = new Map,
    this.users = I(e=>new f(this,e)),
    this.channels = I((e,t)=>E.create(this, e, t)),
    this.guilds = I(e=>new m(this,e))
}

EDIT: source-code that is causing the bug

RPC/src/Client.js

Lines 46 to 92 in 175aa54

constructor(options = {}) {
super(Object.assign({ _tokenType: 'Bearer' }, options));
this.accessToken = null;
this.clientID = null;
/**
* Application used in this client
* @type {?ClientApplication}
*/
this.application = null;
/**
* User used in this application
* @type {?User}
*/
this.user = null;
const Transport = transports[options.transport];
if (!Transport)
throw new TypeError('RPC_INVALID_TRANSPORT', options.transport);
/**
* Raw transport userd
* @type {RPCTransport}
*/
this.transport = new Transport(this);
this.transport.on('message', this._onRpcMessage.bind(this));
/**
* Map of nonces being expected from the transport
* @type {Map}
* @private
*/
this._expecting = new Map();
/**
* Map of current subscriptions
* @type {Map}
* @private
*/
this._subscriptions = new Map();
this.users = createCache((data) => new User(this, data));
this.channels = createCache((data, guild) => Channel.create(this, data, guild));
this.guilds = createCache((data) => new Guild(this, data));
}

connection timeout

at setTimeout (C:\Users\xande\Desktop\program\node_modules\discord-rpc\src\Client.js:109)
Code:

const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const startTimestamp = new Date();
var login = store.get('logininfomation');
socket.emit('DiscordUpateRequest', login.ID, socket.io.engine.id);
console.log("Discord connecting");
rpc.on('ready', () => {
console.log("Connected to discord");
var login = store.get('logininfomation');
if(login){
socket.emit('DiscordUpateRequest', login.ID, socket.io.engine.id);
}
setInterval(() => {
var login = store.get('logininfomation');
socket.emit('DiscordUpateRequest', login.ID, socket.io.engine.id);
}, 5000);
});
async function updateActivity(Data, amount) {
console.log("Updating discord status");
if (!rpc) return;
rpc.setActivity({
details: @+Data.username+ | ++Data.likes,
state: Together with +amount+ other,
startTimestamp,
largeImageKey: "logo",
largeImageText: "McDivision",
instance: false,
});
const startTimestamp = new Date();
}
rpc.login("386928094856085516").catch(console.error);

completely broken in firefox 60

Does not load at all due to throws

TypeError: can't convert undefined to object

inspected with dev tools on a development build found

  static mixin(store, ignored) {
    Object.getOwnPropertyNames(Collection.prototype)
      .concat(Object.getOwnPropertyNames(Map.prototype)).forEach(prop => {

Collection here is not a function

Issue with spread operator in client.js

using type script the spread operator is not recognized as an operator thus creating this error

[14:54:37]  ionic-app-script task: "build"
[14:54:37]  Error: ./node_modules/discord-rpc/src/client.js Module parse failed: Unexpected token (637:8) You may need
            an appropriate loader to handle this file type. | return this.request(RPCCommands.GET_RELATIONSHIPS) |
            .then((o) => o.relationships.map((r) => ({ | ...r, | type: types[r.type], | }))); @
            ./node_modules/discord-rpc/src/index.js 6:10-29 @ ./src/providers/discord.ts @ ./src/app/app.module.ts @
            ./src/app/main.ts
Error: ./node_modules/discord-rpc/src/client.js
Module parse failed: Unexpected token (637:8)
You may need an appropriate loader to handle this file type.
|     return this.request(RPCCommands.GET_RELATIONSHIPS)
|       .then((o) => o.relationships.map((r) => ({
|         ...r,
|         type: types[r.type],
|       })));
 @ ./node_modules/discord-rpc/src/index.js 6:10-29
 @ ./src/providers/discord.ts
 @ ./src/app/app.module.ts
 @ ./src/app/main.ts
    at new BuildError (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at callback (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/@ionic/app-scripts/dist/webpack.js:121:28)
    at emitRecords.err (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/webpack/lib/Compiler.js:265:13)
    at Compiler.emitRecords (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/webpack/lib/Compiler.js:371:38)
    at emitAssets.err (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/webpack/lib/Compiler.js:258:10)
    at applyPluginsAsyncSeries1.err (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/webpack/lib/Compiler.js:364:12)
    at next (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/Users/nicklabrecque/Documents/apps/Seige-Craft/node_modules/webpack/lib/Compiler.js:361:9)

update the getRelationships function to

getRelationships() {
    const types = Object.keys(RelationshipTypes);
    return this.request(RPCCommands.GET_RELATIONSHIPS)
      .then((o) => o.relationships.map((r) => Object.assign({}, r, {type: types[r.type]})));
  }

Unknown Error when trying to connect to a bot without a user (Example)

Electron works fine and the window appears, but the console is literally flooded by errors.
Edit: And the Rich Presence doesn't appear on the bot neither on the bot owner's account.
image
I noticed that all ~15 Seconds a new UnhandledPromiseRejectionWarning appears in the console.

setInterval(() => {
setActivity();
}, 15e3);
});

That could be the error, since setActivity() is getting called every 15 Seconds.
Node: v8.9.1
NPM: v5.5.1
Discord-RPC: 3.0.0-beta.2
PS: I didn't change anything in the .setActivity() Function.

Does it work?

Hi there,

AFAIK, only some selected developers can only use the RPC feature (Discord Gamebridge SDK). I recalled last month that I was able to use RPC, but now it doesn't work.

Thanks

Catch if user closed Discord?

Is there any way to detect if the user closed Discord to start some sort of an automatic reconnect if you restart Discord?

Icons not loading in user.

I had it working at one moment, but than I made a new application in the developer portal, changed the clientID in my app, and setup the icons correctly, but now they arn't their in the profile status. Is it a issue where the icons need to get passed by verification for 24 hours or something?

RPCClient Error

Trying to use discord-rpc (with transport: 'ipc'), but getting this error:

TypeError: Transport is not a constructor
    at new RPCClient (Client.js:67)
    ...

in src/Client.js:67. I checked both Client.js and transports/IPC.js but nothing seems off ๐Ÿค”

Reconnect Error

When a user don't have discord open RPC don't start but If want to Reconnect like this :

 rpc.connect(clientId).catch((data) => {
            console.log("Discord RPC Error: " + data.toString())
        });

or:

rpc.login({clientId:clientId}).catch((data) => {
            console.log("Discord RPC Error: " + data.toString())
});

I got:

Error: Could not connect
   at Socket.onerror (H:\dev\fl0wrpc\node_modules\discord-rpc\src\transports\IPC.js:32:16)
   at Object.onceWrapper (events.js:315:30)
   at emitOne (events.js:116:13)
   at Socket.emit (events.js:211:7)
   at emitErrorNT (internal/streams/destroy.js:64:8)
   at _combinedTickCallback (internal/process/next_tick.js:138:11)
   at process._tickCallback (internal/process/next_tick.js:180:9)```

Issue logging in on v3.0.0-beta.9

On version 3.0.0-beta.9 there is an issue when calling the login function on a Client object. When attempting to login, the following error message is shown:

timeout.unref is not a function TypeError: timeout.unref is not a function

Reverting to 3.0.0-beta.8 fixed this issue, so there is likely something wrong in the library.

Example not working

Getting this error while trying the example i will confirm that
1st) Discord client is on
2nd) discord detects the game

{ Error: connect ENOENT \\?\pipe\discord-ipc-0
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'connect',
  address: '\\\\?\\pipe\\discord-ipc-0' }```

Problem setting this up with Electron

I'm trying to add rich presence to an electron app.

I've tried the default code:
After accepting discord auth, it redirects to my redirect Url, but not access token, I got this instead : http://localhost:4242/oauth/redirect#error=invalid_scope
So I tried removing scopes. I just kept rpc.api scope.
This time, I get the token.

But when I try to

client.login(config.clientId, {
        accessToken: token,
        scopes     : config.scopes
});

all I get is

https://i.imgur.com/sgqLe8I.png

Could you help on that ?
Thanks

Transport requests never reject

I have

      try {
        let result = await rpc.setActivity(status)
        console.log(result)
      } catch (e) {
        console.log(e)
      } finally {
        console.log('finally')
      }

If using IPC and Discord has been closed before running this, the catch and finally block will never execute.

MacOS IPC Path broken with modified TMPDIR

The IPC path on MacOS Mojave is here on my system:

$ find /private/var/folders -name "*discord-ipc*" 2> /dev/null

/private/var/folders/kh/388s01ns6r9480zhlk51nb200000gn/T/discord-ipc-0

I had to modify the ipc.js file to get this working.

I'm assuming that this path is slightly different on people's systems, but a code fix for Darwin system to determine the correct path under /private/var/folders would be very helpful.

I am not using this code directly, but it is a dependency for a plugin I use in my IDE.

Thanks!

sendJoinRequest callback?

I honestly have no idea how the "Ask to Join" feature works. It seems so simple with the C++ lib, but i don't know c++ so I can't use it. I'm assuming every time someone clicks the "join" button on my profile, some callback is supposed to fire. I can't figure out how all this works, and some examples would be very much appreciated. No one seems to know anything about this on the official discordjs discord server. Thanks.

IPC Transport Current User issue

When I listen on the 'message' event being emitted by the transport. I can see the User object inside the data as expected when cmd == Dispatch and evt == Ready.

However, the client.user object is {}.

Also, would it make sense to emit the connected event after the user has been set?

RPC/src/Client.js

Lines 157 to 159 in 175aa54

this.emit('connected');
if (message.data.user)
this.user = this.users.create(message.data.user);

Incorrect OAuth token flow

It seems as if the token flow query parameters are incorrect in the authorize() function. Currently it looks like this:

const response = await this.fetch('POST', '/oauth2/token', {
  data: new URLSearchParams({
    client_id: this.clientId,
    code,
    grant_type: 'authorization_code',
    redirect_uri: redirectUri,
  }),
});

It seems to be missing the client_secret and scope, as is required for the OAuth token flow. I can open a PR if wanted.

code: 4000 No Client ID Specified

I had to downgrade my discord-rpc version due to this annoying error that does not make sense.
"{ code: 4000, message: 'No Client ID Specified' }"

The NPM/Node App we have created is having issues because of the new discord-rpc update, its not the only thing that has had an update and is going wrong. We have specified everything and it worked perfectly before, this is the console log

Rich Presence plugin starting
Version: 1.0.0
Platform: win32
Startup parameters:
{ _: [], help: false, version: false, dev: true, '$0': 'index.js' }
Connected to ETCARS
Game detected: ETS2
Using Discord Application ID 432559364772200479
{ code: 4000, message: 'No Client ID Specified' }

No matter what scopes are chosen discord only authenticates with 2

here is my login line, I'm using IPC transfer protocol.
client.login({clientId: creds.clientId, clientSecret: creds.clientSecret, scopes:["rpc.api", "rpc", "rpc.notifications.read"]});

Maybe I'm misunderstanding how RPC is allowed to be used, but I think that I should be able to subscribe to notification events with the "NOTIFICATION_CREATE" event.

However after authenticating with discord
image

The dev console spits out this update (Sensitive data removed obviously):
cmd: "AUTHENTICATE"
data:
expires: "2019-01-22T16:29:25.258000+00:00"
scopes: Array(2)
0: "rpc"
1: "identify"
length: 2

Additionally the notification_create event never receives any updates (it's registered in the "ready" event listener).

Thanks!

Throws Object.entries is not a function.

Hey there I'm using Brackets API and discord-rpc for Rich Presence integration.
and when using it the API just shouts at me

[NodeDomain] Error loading domain "Client": Unable to load one of the modules: C:/Users/win10/AppData/Roaming/Brackets/extensions/user/RichPresence/Client, reason: Object.entries is not a function

Client.js:

(function() {
    
    const Discord = require('discord-rpc');
        
    /**
     * @private
     */
    function startClient() {
        
        const Client = new Discord.Client({transports: 'ipc'});

        Client.login("403248544443531265").catch(e => console.error);
        
    }
    
    /**
     * Initializes the test domain with several test commands.
     * @param {DomainManager} domainManager The DomainManager for the server
     */
    function init(domainManager) {
        if (!domainManager.hasDomain("Client")) {
            domainManager.registerDomain("Client");
        }
        domainManager.registerCommand(
            "Client",       // domain name
            "Client",    // command name
            startClient,   // command handler function
            false,          // this command is synchronous in Node
            ""
        );        
    }
    
    exports.init = init;
    
})();

"WebSocketTransport.onOpen" cannot set 'endpoint' of undefined

I have never ran into an issue before when implementing my source in the console. We have started trying to implement it within an electron environment and we have been consistently getting this error.

Uncaught TypeError: Cannot set property 'endpoint' of undefined at WebSocketTransport.onOpen
(node_modules\discord-rpc\src\transports\WebSocket.js:52)

IPC Path Problem On Ubuntu 18.04

Problem

So... On Ubuntu 18.04 path to discord ipc is /run/user/1000/snap.discord/discord-ipc-{Id}
instead of /run/user/1000/discord-ipc-{Id} with cause Could not connect error

WorkAround For Ubuntu Users

Hard code new path to every discord-rpc/src/transports/IPC.js file on your computer.
Path is on line 128.

return `${prefix.replace(/\/$/, '')}/snap.discord/discord-ipc-${id}`;

Allow changing status type

Allow changing status type (playing, watching, listening) for Rich Presence.

Note an example of a listening Rich Presence on the developers testing the Spotify integration's Rich Presences.

Also, discordjs/discord.js#2103 is a (closed) discord.js issue with an example of a rich presence type:

client.user.setPresence({
    activity: {
//[...]
        name: "",
        type: "LISTENING",
        details: "",
        state: ""
//[...]
    }
});```

[Question] - Main README lists `scopes` parameter but example does not

Can you elaborate? I checked the source was trying to understand if there were default scopes (there doesn't seem to be).

My guess:

  • If your app is approved by Discord and you use websocket transport, you have to request proper scope
  • If you're in development mode (using ipc transport) you don't require the scope

If this is correct, I can issue a PR with added documentation perhaps! Either way, fill me in and thanks so much for you work on this. We've almost got the whole invite/approval flow working but we have a bug (on our end I'm pretty sure)

<3

Author thinks breaking the package on purpose is not an issue

beta versions of rpc are purposely pinned to discord.js master branch.

And that's why things will break eventually.

Does this mean "my beta version package is not supposed to work, so even if it works for you now, I am making sure that it will not work eventually"?

This is a real issue, if the author thinks none of the reported issues are meaningful to you, or you think you are exhausted to treat other devs properly, you are welcome to close the whole issue board.

WebSocket transport doesn't work when IPC does

So far as I can tell, the WebSocket simply fails to open the connection, but IPC succeeds with the exact same setup and information (just switching the transport value when creating Discord.Client). I need the WS version to work because I need to use this through Browserify (but this is still failing when running through Node before Browserify). I don't know what to debug myself, but if you could give me a direction to go in, I can get you whatever information you need. I have debugged websocket.js a bit, and found that ws has a ready state of 3 immediately after it tries instantiating it, so the connection is just silently failing for whatever reason.

Discord RPC not changing activity or freezes (client not destroying or clearing, even after closing client)

Recently a discord update was published (or it seems like it) and ever since the discordjs/RPC npm package has been having many issues. One of them being that discord's rpc activity does not change and will just be frozen until discord is restarted (even after node client is closed).

Example:

Code used: https://github.com/VirtualTruckerRPC/Virtual-Trucker-Rich-Presence/tree/dev

Is this a known issue? As it seems to be quite a major bug.

How to use this with Chrome Extension

Hello, I want to ask if there is an option to use this RPC with Chrome Extension, I'm not sure const { Client } = require("discord-rpc"); cuz I made it that way and it didn't work. Do you have any idea how to do it? (I'm creating Discord RPC for Netflix to show what are you watching etc.)

Example?

How would you use this next to Discord.js in a pure node env?
Bot purpose.

Spread Operator - Unexpected Token SyntaxError

When I execute npm start, discord-rpc throws this error:

App threw an error during load
C:\Users\CORE I3\Downloads\CR-APP\node_modules\discord-rpc\src\client.js:637
        ...r,
        ^^^

SyntaxError: Unexpected token ...
    at Object.runInThisContext (vm.js:116:10)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\CORE I3\Downloads\CR-APP\node_modules\discord-rpc\src\index.js:6:11)

I've found this issue here too: #74
And the solve is to "upgranding my tooling", but I need exactly what to upgrade. I had already moved to the newest version of NodeJS and NPM, but that didn't solved that, so I returned to 8.17.0 version of NodeJS (and 6.13.4 of NPM) and I'm there right now.

And there was a time that discord-rich-presence package solved that error, but now it keeps throwing this error (on their node_modules) using it or using discord-rpc.

I know that this doesn't happen on 3.0.1 version of discord-rpc. But npm started now installing 3.1.0 even if package.json specify the "3.0.1" version. Please tell me if i'm doing something wrong or how do I tell npm to not upgrade to 3.1.0, excuse me if I skipped some info about this too.

Path Error

ERROR in ./node_modules/snekfetch/src/index.js
Module not found: Error: Can't resolve '../package' in 'mypath\node_modules\snekfetch\src'
resolve '../package' in 'mypath\node_modules\snekfetch\src'
using description file: mypath\node_modules\snekfetch\package.json (relative path: ./src)
after using description file: mypath\node_modules\snekfetch\package.json (relative path: ./src)
using description file: mypath\node_modules\snekfetch\package.json (relative path: ./package)
no extension
mypath\node_modules\snekfetch\package doesn't exist
.ts
mypath\node_modules\snekfetch\package.ts doesn't exist
.js
mypath\node_modules\snekfetch\package.js doesn't exist
as directory
mypath\node_modules\snekfetch\package doesn't exist
[mypath\node_modules\snekfetch\package]
[mypath\node_modules\snekfetch\package.ts]
[mypath\node_modules\snekfetch\package.js]
[mypath\node_modules\snekfetch\package]
@ ./node_modules/snekfetch/src/index.js 3:16-37
@ ./node_modules/snekfetch/index.js
@ ./node_modules/snekfetch/esm.mjs
@ ./node_modules/discord-rpc/src/Client.js
@ ./node_modules/discord-rpc/src/index.js
@ ./src/app/shared/services/user/user.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts

RPC Connection Timeout

I've been recently getting this RPC_CONNECTION_TIMEOUT for no apparent reason. It was working but then suddenly stopped and I kept on getting this error.
image

Fix repo hash of discord.js in package.json

"discord.js": "github:discordjs/discord.js",

Due to the package.json depends on develop branch ( master ) of discord.js
This package will break eventually when api of discord.js changed.
The published version (3.0.0-beta.11) on npm is also affected this problem and completely broken

It may be better to depend on a API stable tag (11.3-dev maybe) or a commit hash that you confirm this package works correctly with it.

My RPC issues

First one is that nobody wants to even help with it on your official discord.js server
Second is very bad docs like in example is:

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

and then in docs is:

  /**
   * @typedef {RPCLoginOptions}
   * @param {string} [clientSecret] Client secret
   * @param {string} [accessToken] Access token
   * @param {string} [rpcToken] RPC token
   * @param {string} [tokenEndpoint] Token endpoint
   */

where in this is something about scopes?

And on webpage https://discord.js.org/#/docs/rpc/master/class/RPCClient is just that xD

Third one is about connection, websocket doesn't work for me for unknown reason but when I asked on official server, of course nobody wanted to help, even devs, there were just messages from people who doesn't like RPC idea at all, so very good support, anyways ipc option doesn't work at all, I tried to use it but it just throws errors, something with constructor, idk really why.

Another issue is that you don't merge PRs there are two of them right now, and one is waiting 10 days. For me, it all is silly cuz like RPC is part of discord, and discord.js too. So why do you treat it like that?...

Error this.client.rest.endpoint

trying with nodejs code:

var RPC=require('discord-rpc');
const clientId = 'XXXXXXXXXXXXXXXX';
const scopes = ['rpc', 'rpc.api', 'messages.read'];

const client = new RPC.Client({ transport: 'websocket' });

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

    client.selectVoiceChannel('81384788862181376');
});

// Log in to RPC with client id
client.login({ clientId, scopes });

I get the error

discordtest\node_modules\discord-rpc\src\transports\WebSocket.js:52
    this.client.rest.endpoint = `http://${this.hostAndPort}`;
                              ^

TypeError: Cannot set property 'endpoint' of undefined
    at WebSocketTransport.onOpen (C:\Users\pbx06\WebstormProjects\discordtest\node_modules\discord-rpc\src\transports\WebSocket.js:52:31)
    at WebSocket.onOpen (C:\Users\pbx06\WebstormProjects\discordtest\node_modules\discord-rpc\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (events.js:182:13)
    at WebSocket.setSocket (C:\Users\pbx06\WebstormProjects\discordtest\node_modules\discord-rpc\node_modules\ws\lib\websocket.js:151:10)
    at ClientRequest.req.on (C:\Users\pbx06\WebstormProjects\discordtest\node_modules\discord-rpc\node_modules\ws\lib\websocket.js:602:10)
    at ClientRequest.emit (events.js:182:13)
    at Socket.socketOnData (_http_client.js:453:11)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:280:12)
    at readableAddChunk (_stream_readable.js:265:11)
Waiting for the debugger to disconnect...

Process finished with exit code 1

Cannot connect to RPC

I use an extension into VSCode to modify my Rich Presence but when I start VSCode, it says "Cannot connect to Discord RPC : write EPIPE" :/

I'm on Discord PTB and I have VSCode 1.33.0.

Error with electron probaly.

C:\Users\yeetus\Desktop\RPC-master>npm start example
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\yeetus\AppData\Roaming\npm-cache\_logs\2018-10-15T19_59_16_261Z-debug.log

C:\Users\yeetus\Desktop\RPC-master>npm run example

> [email protected] example C:\Users\yeetus\Desktop\RPC-master
> electron example/main.js

^ Keeps stitting at main.js
How to repruduce?
Download the project as zip.
Decomplie it.
Go inside rpc-master/rpc-master
Open CMD inside the folder
Write npm run example

Failed to construct WebSocket

By using following code:

 const RPCClient = window.DiscordRPC.Client;
  
  const client = new RPCClient({
  	OAUTH2_CLIENT_ID: 'xxxxxxxxxx'
	});
  
  	client.on('ready', () => {
  	console.log('Authenticated!');
  	console.log('User:' `${client.user.username}#${client.user.discriminator}`, client.user.id)
  	console.log('Application:', client.application.name, client.application.id);
  	client.getChannels().then(res => {
    // res is an array of channels :)
 	 });
  });
  
  client.connect("xxxxxxxxxxxxx");  

this error occurs:

Uncaught DOMException: Failed to construct 'WebSocket': The subprotocol '[object Object]' is invalid.
    at RPCClient.connect (file:///Users/xxxxx/Desktop/test.html:418:21)
    at Client.connect (file:///Users/xxxx/Desktop/test.html:2177:23)
    at file:///Users/xxx/Desktop/test.html:3254:10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.