- Get client ID and client secret in Discord Developer Portal and edit
.env
- Launch VRChat and Discord (not in browser but standalone application)
- Enable OSC in VRChat
- Run the followings
npm install
npm run serve
DISCORD_CLIENT_ID=1234123412341234123 | |
DISCORD_CLIENT_SECRET=123456789abcdefABCDEF_123456789a | |
PORT=53134 |
import { Server } from 'node-osc'; | |
import RPC from "discord-rpc"; | |
import * as dotenv from 'dotenv'; | |
const server = new Server(9001, '0.0.0.0'); // from VRChat | |
const client = new RPC.Client({ transport: "ipc" }); // to Discord | |
server.on('/avatar/parameters/MuteSelf', async (params) => { | |
const vc = await client.getVoiceSettings(); | |
console.log(params[1]) | |
await client.setVoiceSettings({ | |
mute: !params[1], | |
}); | |
}); | |
(async () => { | |
dotenv.config() | |
const port = process.env.PORT; | |
await client.login({ | |
clientId: process.env.DISCORD_CLIENT_ID, | |
clientSecret: process.env.DISCORD_CLIENT_SECRET, | |
scopes: ["rpc", "rpc.voice.write"], | |
redirectUri: `http://localhost:${port}`, | |
}); | |
})(); |
{ | |
"name": "vrchat-discord-mute-syncer", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"type": "module", | |
"scripts": { | |
"serve": "node index.js", | |
"build": "nexe --build index.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "wararyo", | |
"license": "MIT", | |
"dependencies": { | |
"discord-rpc": "^4.0.1", | |
"dotenv": "^16.0.1", | |
"express": "^4.18.1", | |
"node-fetch": "^3.2.10", | |
"node-osc": "^8.0.5", | |
"open": "^8.4.0" | |
}, | |
"devDependencies": { | |
"nexe": "^4.0.0-rc.1" | |
} | |
} |