RPC
RPC copied to clipboard
Error: child "id" fails because ["id" must be a string]
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\transports\ipc.js:138:18
at decode (C:\Users\USER\Documents\DRPC\node_modules\discord-rpc\src\transports\ipc.js:92:5)
at Socket.<anonymous> (C:\Users\USER\Documents\DRPC\node_modules\discord-rpc\src\transports\ipc.js:120:7)
at Socket.emit (node:events:513:28)
at emitReadable_ (node:internal/streams/readable:590:12)
at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 4000,
data: {
code: 4000,
message: 'child "id" fails because ["id" must be a string]'
}
}
heres my code:
const rpc = require("discord-rpc");
const client = new rpc.Client({ transport: 'ipc' });
const config = require('./config.json');
require('dotenv').config();
client.login({ clientId: config.ClientID }).catch(console.error);
client.on('ready', () => {
console.log('[DEBUG] Presence now active!')
console.log('[WARN] Do not close this Console as it will terminate the rpc')
console.log('=================== Error Output ===================')
client.setActivity({
details: config.Details,
state: config.State,
startTimestamp: Date.now(),
largeImageKey: config.LargeImage,
largeImageText: config.LargeImageText,
smallImageKey: config.SmallImage,
smallImageText: config.SmallImageText,
// use an environment variable to set the matchSecret
matchSecret: process.env.MATCH_SECRET,
joinSecret: process.env.JOIN_SECRET,
spectateSecret: process.env.SPECTATE_SECRET,
partyId: process.env.PARTY_ID,
partySize: parseInt(process.env.PARTY_SIZE,10),
partyMax: parseInt(process.env.PARTY_MAX,10),
})
const lobby = client.createLobby(2, 12, {
id: '1234567890',
secret: '1234567890password',
}).then((data) => {
})
client.connectToLobby(lobby, process.env.LOBBY_SECRET)
})
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": ""
}