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.<anonymous> (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:5)
at Socket.<anonymous> (E:\DiscordRPC\node_modules\discord-rpc\src\transports\ipc.js:120:7)
at Socket.emit (node:events:527:28)
at emitReadable_ (node:internal/streams/readable:578:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
PS E:\DiscordRPC>
The problem was caused because of variable naming scheme.
In my code, to store my application's client id, I declared a variable as -
const CLIENT_ID = process.env.CLIENT_ID
However, upon inspecting the file client.js in the src folder of discord-rpc package, I found that the object which is being passed as a parameter to the login method (line 135 of the same file) is being destructured to its two keys. This destructuring caused the error I received above.
I think this shouldn't be the case since people can name their variables however they see fit. I think this issue can be fixed by refactoring the code.
While trying to make my custom rich presence for discord, I encountered the following error
The problem was caused because of variable naming scheme.
In my code, to store my application's client id, I declared a variable as -
However, upon inspecting the file client.js in the src folder of discord-rpc package, I found that the object which is being passed as a parameter to the login method (line 135 of the same file) is being destructured to its two keys. This destructuring caused the error I received above. I think this shouldn't be the case since people can name their variables however they see fit. I think this issue can be fixed by refactoring the code.