qwertyquerty/pypresence

Unsubscribe / Unregister is not working properly.

gitagogaming opened this issue · 2 comments

Unsubscribing from a previous event is not working properly.

I've tried numerous things and looked into the documentation for Discord RPC and things appear to be lining up proper.. but
I do believe theres something underlying in payloads.py or client.py that is causing an issue..

Sample Unsubscribe Statement
self.c.unregister_event('SPEAKING_STOP', {'channel_id': channel_id})

Here is an example of a subscribe & unsubscribe sent by the library inside of client.py

{
  "cmd": "SUBSCRIBE",
  "args": {
    "channel_id": "969018109904179254"
  },
  "evt": "SPEAKING_STOP",
  "nonce": "1663522219.63430929183959960938"
}


{
  "cmd": "UNSUBSCRIBE",
  "args": {
    "channel_id": "969018109904179254"
  },
  "evt": "SPEAKING_STOP",
  "nonce": "1663522219.62731003761291503906"
}

here is a picture to show that the library does appear to unregister it and remove it from _events, but it still triggers on this event as usual even though it appears it should not be..

image

when we unsubscribe this is what comes back which appears to be 'evt' in there twice which is not expected based on the docs from https://discord.com/developers/docs/topics/rpc#unsubscribe

{'cmd': 'UNSUBSCRIBE', 'data': {'evt': 'SPEAKING_START'}, 'evt': None, 'nonce': '1663525936.63293623924255371094'}

I resolved this issue - It was caused by an improper channel ID being passed along to unsubscribe to a particular event and instead of throwing an error the library just removes it from the list since it doesnt compare for channel_id and only the event name.