I encountered a problem that my script does not send the changed data to Discord.
All other functionality works well. What could be the problem?
Here’s the code:
var send = WebSocket.prototype.send;
WebSocket.prototype.send = function (data) {
if (WebSocket.prototype.toString.call(data) === "[object ArrayBuffer]") {
var array = new Uint8Array(data);
var modules = DiscordNative.nativeModules.requireModule('discord_erlpack');
var unpackeddata = modules.unpack(array);
console.Log("(WS LOG) received wsdata -> " + JSON.stringify(unpackeddata));
if (unpackeddata.op == 4) {
unpackeddata.d.self_mute = true;
unpackeddata.d.self_deaf = true;
unpackeddata.d.self_video = true;
console.log("WS Packet 4")
} else if (unpackeddata.op == 12) {
for (var stream of unpackeddata.d.streams) {
stream.quality = 1;
stream.max_bitrate = 8000;
stream.max_framerate = 10;
console.log("WS Packet 12")
}
} else if (unpackeddata.op == 24) {
unpackeddata.d.type = 123;
unpackeddata.d.limit = 123;
unpackeddata.d.offset = 123;
console.log("WS Packet 24");
}
var packed = modules.pack(unpackeddata);
var buffer = packed.buffer;
array = new Uint8Array(buffer);
data = array;
} else {
console.log("(WS LOG) received wsdata -> " + data);
}
return send.apply(this, [data]);
}