discordjs / RPC

A simple RPC client for Discord
MIT License
474 stars 192 forks source link

Error this.client.rest.endpoint #44

Closed pabx06 closed 6 years ago

pabx06 commented 6 years ago

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
didinele commented 6 years ago

Hmm, this does not look like the latest commit hash: 905c28239bdb86e4da2d17954429057b02b91ffe

Also this seems to have been fixed on this commit: 624eac1547b6047997923cc643004f5042f9ad61

Could try re-installing the lib?

devsnek commented 6 years ago

this was fixed in https://github.com/discordjs/RPC/commit/624eac1547b6047997923cc643004f5042f9ad61