Fiddlekins / podbot

A Discord bot designed to record voice chat audio, aimed at recording a specific podcast
82 stars 16 forks source link

Fix missing dependency + setActivity in rewrite #15

Closed shikhir-arora closed 5 years ago

shikhir-arora commented 6 years ago

9|podbot   | TypeError: secretbox.open is not a function
9|podbot   |     at VoiceReceiver.handlePacket (/home/vlexar/main/vlexar/podbot/podbot/node_modules/discord.js/src/client/voice/receiver/VoiceReceiver.js:150:26)
9|podbot   |     at Socket.VoiceReceiver._listener.msg (/home/vlexar/main/vlexar/podbot/podbot/node_modules/discord.js/src/client/voice/receiver/VoiceReceiver.js:57:14)
9|podbot   |     at Socket.emit (events.js:160:13)
9|podbot   |     at UDP.onMessage [as onmessage] (dgram.js:659:8)
9|podbot   | (node:26298) DeprecationWarning: ClientUser#setGame: use ClientUser#setActivity instead

🙂

shikhir-arora commented 6 years ago

Having just sodium doesn't fix the error with discord.js 11.3 -- it fixes the instant join/leave -> recreate, but the minute any packets come through it throws the same error (so if everyone is muted sodium works, otherwise it crashes).

Using discord.js 12.0-dev is completely refactored from the VoiceReceiver which has been rewritten (presumably to use their prism library). The bot joins and can receive packets fine, but methods like VoiceReceiver#destroy don't exist at all as it's been refactored.

Since I noticed this issue was fixed in the 12.0-dev branch by updating the wrappers (see here) - I was able to fix this error by using the later (>=0.7.0) libsodium-wrappers with the discord.js library. In node_modules the libsodium-wrappers should be at version >=0.7.0 as they are on the discord.js 12.0-dev build.

This combination fixes the crash and allows the bot to function normally (/podon and /podoff).

Fiddlekins commented 6 years ago

Good catch, I was messing about trying to decide which sodium dep to use and guess I inadvertently settled for neither...

Anyway, excuse my ignorance, but is 12.0-dev the master branch for discord.js? Also, do you need both sodium and libsodium-wrappers? I thought it was one or the other, where sodium has better performance.

Other than that, I tried using latest version of one of them but had problems (which the update you linked looks like it should fix) and a bit of investigating suggested that an earlier version was required for things to work.

I can't see the fix that would enable 0.7.3 of libsodium-wrappers to work on the 11.3-dev branch. If I were to guess, I'd say that since you have both sodium and libsodium-wrappers installed, sodium takes priority so the issue with libsodium-wrappers doesn't occur despite the lack of fix?

shikhir-arora commented 6 years ago

That may be it, I did end up building sodium from source. But even 11.3 has libsodium-wrappers and sodium (just an earlier version of wrappers) - so I can't see it hurting here.

Yeah, 12.0-dev is master. They have not finished rewriting the AudioReceiver yet, so that is not functional.

shikhir-arora commented 6 years ago

Were you able to see anything further?

Fiddlekins commented 6 years ago

Sorry man, I wanted to just test it to see what works what doesn't but sodium stopped compiling without error and I haven't had the time to go through it all yet.

shikhir-arora commented 6 years ago

Not a problem 👍

Fiddlekins commented 5 years ago

Yeah in hindsight I never got around to finishing this up. Anyway, sodium dependency has been updated and the API for setActivity has changed again (I ran out of time tonight so that line is just commented out on master right now, I'll fix it tomorrow)