Skip to content

Instantly share code, notes, and snippets.

@wararyo
Last active April 18, 2024 09:36
Show Gist options
  • Save wararyo/2197154f229ef49219ba4998ebf29c7f to your computer and use it in GitHub Desktop.
Save wararyo/2197154f229ef49219ba4998ebf29c7f to your computer and use it in GitHub Desktop.
VRChat Discord Mute Syncer

VRChat Discord Mute Syncer

How to run

  1. Get client ID and client secret in Discord Developer Portal and edit .env
  2. Launch VRChat and Discord (not in browser but standalone application)
  3. Enable OSC in VRChat
  4. 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"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment