discordjs / RPC

A simple RPC client for Discord
MIT License
466 stars 191 forks source link

Fix RPC subscription subkey generation on receive #112

Closed Herysia closed 3 years ago

Herysia commented 3 years ago

Fixes an error in _onRpcMessage when handling event message from discord. The subkey generation was using wrong field "args" while discord named it "data" in their Events API.

Fixes #110

Herysia commented 3 years ago

As a side note, this does fix for most of the events but there is still an implementation error for some events. For example, SPEAKING_START and SPEAKING_STOP can be subscribed using a "channel_id" field, and it'll subscribe to every member in the channel (event data will contain "channel_id" and "user_id"). However, with the current implementation the lib will drop the received messages because the event subkey doesn't contain the "user_id" field. It is required to track all users and subscribe to them manually.

Maybe tracking what field is being used for subscribing and use ONLY those fields to generate the subkey.