Closed Hacksore closed 2 years ago
When subscribing to any event I see them firing twice.
Steps to produce:
VOICE_CHANNEL_SELECT
SPEAKING_START
Code for reference/reproduction
const RPC = require("discord-rpc"); const client = new RPC.Client({ transport: "ipc" }); const clientId = "redacted"; const accessToken = "redacted"; client.on("ready", () => { console.log("Authed for user", client.user.username); client.subscribe("VOICE_CHANNEL_SELECT"); }); client.on("VOICE_CHANNEL_SELECT", event => { console.log(event.channel_id); client.subscribe("SPEAKING_START", { channel_id: event.channel_id }); }); client.on("SPEAKING_START", event => { console.log("SPEAKING_START", event); }); // Log in to RPC with access token client.login({ clientId, scopes: ["rpc"], prompt: "none", accessToken });
What I see in the console:
After looking at this again I think it's a rather large PEBCAK. The VOICE_CHANNEL_SELECT must have fired twice, thus creating two listeners.
Mystery solved 😅
When subscribing to any event I see them firing twice.
Steps to produce:
VOICE_CHANNEL_SELECT
SPEAKING_START
VOICE_CHANNEL_SELECT
andSPEAKING_START
Code for reference/reproduction
What I see in the console: