Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support to do things like
bot.wavelink.set_serializer(ujson.dumps)
and pretty much any other JSON encoder that dumps to strings or bytes. I did not know a better way to do this other than 3 attributes on all classes to make sure they are being created correctly for any future cases.I left a note regarding sending bytes, as it would be technically more efficient, yet Lavalink rejects binary traffic for now. Might want to request that in upstream.
I've tested the basic idea of dumping and then using
send_str
in production with orjson and thesend_json
from aiohttp pretty much dumps it and sends it then anyways, so there is no overhead created here, yet using a kwarg to thesend_json
would not allow JSON encoders that return bytes, so I decided for this way.