#discord-rpc
110 messages Β· Page 1 of 1 (latest)
Link still seems to be broken?
Still lacking documentation.
I can run the same code when running from my local windows PC but when I try to run it on my server, it crashes with the following error. (I did edit the code here ). Anyone know why the RPC cannot connect when ran from a server?
Error: Could not connect
at Socket.onerror (/home/marv1/apps/RPC/src/transports/ipc.js:32:16)
at Object.onceWrapper (node:events:628:26)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/stre...
While attempting to create a lobby, I get this error
C:\Users\USER\Documents\DRPC\node_modules\discord-rpc\src\client.js:178
const e = new Error(message.data.message);
^
Error: child "id" fails because ["id" must be a string]
at RPCClient._onRpcMessage (C:\Users\USER\Documents\DRPC\node_modules\discord-rpc\src\client.js:178:19)
at IPCTransport.emit (node:events:513:28)
at C:\Users\USER\Documents\DRPC\node_modules\discord-rpc\src\transpo...
in case this is helpful, heres my package.json file:
{
"dependencies": {
"discord-rpc": "^4.0.1",
"dotenv": "^16.0.2"
},
"name": "discord-rpc-client",
"version": "1.0.0",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "GPL-3.0-or-later",
"description": ""
}
The link provided in docs is broken and there is no RPC option in the dropdown on the main docs site.
While trying to make my custom rich presence for discord, I encountered the following error
PS E:\DiscordRPC> node index.js
Error: connection closed
at IPCTransport. (E:\DiscordRPC\node_modules\discord-rpc\src\client.js:111:16)
at Object.onceWrapper (node:events:642:26)
at IPCTransport.emit (node:events:527:28)
at E:\DiscordRPC\node_modules\discord-rpc\src\transports\ipc.js:141:18
at decode (E:\DiscordRPC\node_modules\discord-rpc\src\transports\ipc.js:92:...
This pull request aims to fix #173.
I have made appropriate changes to the client.js file in the src folder such that variable naming won't cause the 'connection closed' error. Developers writing code for custom rich presence can use any variable name instead of 'clientId' and 'accessToken' only.
For more info about the error, please check #173
Changes Made
- Removed the destructuring of object 'options' on line 136.
- An array called 'values' now stores the clientId and acc...
This user cold DM'ed me on Discord asking to take a look at this -- this change makes absolutely zero sense and breaks how the login method works. Yes, it works if you pass a perfect object where the first two key/value pairs happen to be clientId and then accessToken, but in any other scenario it does not. It is an object, and it is being destructured, as it should be.
There's also the problem that redirect_uri is a requirement.
There's also the problem that
redirect_uriis a requirement.
That wasn't a requirement when I made this PR, but RPC is getting a rewrite anyway.
For some reason, the code works on my host machine but when I try to make it into a docker container, it gives me this error:
Error: Could not connect
at Socket.onerror (/root/trollge/node_modules/discord-rpc/src/transports/ipc.js:32:16)
at Object.onceWrapper (events.js:421:26)
at Socket.emit (events.js:314:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/p...
didnt solve it for me sandwichDev
Still no docs at all
exports.ActivityTypes = {
PLAYING: 0,
WATCHING: 3
}
Only PLAYING and WATCHING are allowed by RPC. Everything else results in an error.
Just to clarify something: This PR was only meant to provide feature-complete integration according to the API docs, assuming in the future the use of these constants would open up to the public. I'm aware it's not working right now (since there is no public access to most of the constants) and I'm willing to close this request if there's no need for it.
Any updates here? Also the link in the README.md is broken too.
See this for reference:
https://github.com/discordjs/RPC/blob/9e7de2a6d917591f10a66389e62e1dc053c04fec/README.md?plain=1#L16
Are there any alternative documentation in the meantime?
Observed bug
Sometimes creating subscriptions or sending commands through IPC would result in the promise never resolving, i.e. the message with the expected nonce never getting received.
Reason
The original code to parse the received IPC packets:
The code has an assumption that a packet will at most one message.
The code will skip the processing of a message i...
Do you have a way for me to reproduce your issue?
I couldn't come up with something that yielded me more than one payload in a message. π
This and the requested change aside, this looks fine to me.
I don't think we want to call console methods internally.
I have no idea what exactly we should do here instead however.
Maybe add an error key to the object in the callback and match on that to emit some event on the RPCClient?
(I have no idea why that function even takes a callback, it looks rather sync to me.)
Here's a reproducible example:
const RPC = require('discord-rpc')
;(async () => {
const client = new RPC.Client({ transport: 'ipc' })
await client.login({
clientId: '',
clientSecret: '',
redirectUri: '',
scopes: ['rpc', 'rpc.voice.read', 'rpc.voice.write'],
})
client.subscribe('VOICE_SETTINGS_UPDATE')
client.setVoiceSettings({ input: { volume: 100 } })
client.setVoiceSettings({ output: { volume: 100 } })
}...
Sounds reasonable. error event could be emitted on the RPCClient with an invalid response error.
I've adjusted the error handling:
https://github.com/discordjs/RPC/blob/4b025cd9c6e3db6688cbe9acdd6d3dc246bf82b7/src/transports/ipc.js#L113
I'm creating a new error to be more descriptive, but the original error is preserved as the cause.
I wrote a simple code to run a custom rich presence on MacOS and tested it too in Windows, but now when I'm using Debian it gives me this error:
> node .
/home/rhaym/Documents/DJS-RichPresence/node_modules/discord-rpc/src/transports/ipc.js:32
reject(new Error('Could not connect'));
^
Error: Could not connect
at Socket.onerror (/home/rhaym/Documents/DJS-RichPresence/node_modules/discord-rpc/src/transports/ipc.js:32:16)
at Object.onceWrapper (nod...
I'm sorry but I just realised the problem is from Discord itself, now installed an update and it got fixed
Is there any reason why this can't be implemented?
Same error but trying in Bun
import {register, Client} from "discord-rpc"
register(':D');
const rpc = new Client({transport: 'ipc'});
rpc.on('ready', () => {
console.log('Client is ready');
})
rpc.login({clientId: ":D});
Enviroment Details
DiscordRPC ^4.0.1
Bun 1.0.22
Running in KDE Neon (Ubuntu)
Hi, sorry if this is the wrong place to ask.
Looking around discord docs, found that discord-rpc is going to be depreciated and will be replaced by Game SDK.
My use case is to control the user's own and other voice channel member's voice settings with hardware controllers.
Doing a quick test tonight, discord.js/RPC just does this, I'm so far happy with the results.
Curious to know if my happiness will go away with an API depreciation.
Thanks!
Is there any reason why this can't be implemented?
Yes, discord ignores any passed value of type.
I think you've already figured it out, then I'll just leave this post for those who, like me, have encountered this problem so they don't have to search for information.
Ever since the new update I can't seem to use buttons but anything else works... Here is an image.
It looks like this is a Discord desktop client issue. I also don't have the buttons when I look on the desktop app (MacOS), but I do see the buttons if I check my profile on the iOS app. Discord are updating profiles with the new compact versions and that's likely messing with / hiding the buttons on purpose to make them more compact.
exports.ActivityTypes = {
PLAYING: 0,
LISTENING: 2,
WATCHING: 3,
COMPETING: 5,
}
Discord had a C++ library called discord-rpc, which they deprecated in favor of their Game SDK. They both let you control RPC.
This unofficial library by Discord.js is coincidentally released under the package discord-rpc, but is unrelated to the deprecated library. You can continue to use it, as Discord are not deprecating the underlying RPC API.
Not very good with js. Also can't seem to find the documentation, so i'm a bit lost. I'm looking for something to replace const client = new rpc.Client({ transport: 'ipc' }) when trying to connect to an already established RPC connection. Calling again just creates a duplicate RPC activity on the user.
Activity Types are now supported in discord rpc - see https://x.com/advaithj1/status/1816655583107510517
code example: https://github.com/th-ch/youtube-music/blob/f2b1e6b6bfa748c82c144d76140248c77bea7569/src/plugins/discord/main.ts#L183-L190
Activity Types are now supported in discord rpc - see https://x.com/advaithj1/status/1816655583107510517 (Jul 26, 2024)
code example: https://github.com/th-ch/youtube-music/blob/f2b1e6b6bfa748c82c144d76140248c77bea7569/src/plugins/discord/main.ts#L183-L190
Yes, I agree, it seems to be working now.
transports/ipc.js
- when ipc was closed, the socket was never set to undefined/null causing a crash
transports/websocket.js
- when closing, websocket was still defined causing a crash.
I think they stop render your own button since you can't click it, others can still see it.
Thank you @n1ckoates! We've went with (xhayper's fork)[https://github.com/xhayper/discord-rpc].
Hey there!
We have detected a security vulnerability in your repository. Please contact us at https://github-scanner.com to get more information on how to fix this issue.
Best regards,
Github Security Team
A simple line that allow you to select Activity Type without causing problem for other unmaintained project if type not specified.
Thank you for investigating how to do this! This getting merged would be very much appreciated.
Only PLAYING and WATCHING are allowed by RPC. Everything else results in an error.
Is this still the case?
no, you can use playing, listening, watching, and competing
Closing as a duplicate of #172. If you want to make a feature request for the guide, you can do so here.
* The {@link https://github.com/discordjs/RPC#readme | @discordjs/rpc} version
Should be screaming snake case:
export const RPC_VERSION = '1' as const;
WeΒ₯re keeping this to discord-rpc, so double-check this file against discord.js and create-discord-bot because those do not haev scoped cliff.toml files.
Might want to revert this version change!
} catch {} // eslint-disable-line no-empty
{} here is redundant. Did you mean to type this as an empty object? If so, use Record<string, never>. {} represents any value except null and undefined.
{} here is redundant. Did you mean to type this as an empty object? If so, use Record<string, never>. {} represents any value except null and undefined.
On latest nodeJS and Angular TS
this.rpc = new RPC.Client({ transport: 'ipc' });
this.rpc.login({ clientId: discordConfig.clientId }).catch(console.error);
The login is catching : "TypeError: setTimeout2 is not a function"
There is also a warning "browser-external:timers:9 Module "timers" has been externalized for browser compatibility. Cannot access"
How is this supposed to work, when api-extractor isnβt a dev dependency at all?
I assume that package isn't possible to use until this is merged with the main repo. Could we ignore that until this merged later on to the main repo, or perhaps I just create a new PR for the main repo for this rewrite instead
The CI on this repository will try to run that on merge (and fail). So if you'd want to ignore this then you probably should also edit the CI to not run (or delete it completely).
discord-rpc
Hi, newer version of Node doesn't install bufferutil nor utf-8-validate by default, yet they are still needed.
The warning comes from Vite. I'm running into the same problem. After running vite build and hosting the resulting bundle in an nginx container, there's a different error message, that _ is not a function. Did you ever solve this issue?
Add the "type" and "name" options to setActivity.
Also the link to the docs doesn't work anymore.
The official Discord JS repo has not been touched since 4 years and wasn't supporting Image URLs as well as updating the type via setActivity()
This branch now allow's the user's to also pass those argument's to setActivity()
Fixed in b42ce4a6341f1773afaea1ae5e203ad9b068f287