Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash receiving private messages #33

Closed
enebe-nb opened this issue Oct 9, 2015 · 10 comments
Closed

Crash receiving private messages #33

enebe-nb opened this issue Oct 9, 2015 · 10 comments

Comments

@enebe-nb
Copy link
Contributor

enebe-nb commented Oct 9, 2015

It seems there's none server when receiving private messages and this causes an error.

first message's error log:

./node_modules/discord.js/lib/channel.js:43
                    throw _iteratorError;
                    ^

TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
    at new Channel (./node_modules/discord.js/lib/channel.js:26:60)
    at Client.addChannel (./node_modules/discord.js/lib/Client.js:1189:28)
    at WebSocket.websocket.onmessage (./node_modules/discord.js/lib/Client.js:1016:25)
    at WebSocket.onMessage (./node_modules/ws/lib/WebSocket.js:414:14)
    at emitTwo (events.js:87:13)
    at WebSocket.emit (events.js:172:7)
    at Receiver.ontext (./node_modules/ws/lib/WebSocket.js:797:10)
    at ./node_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (./node_modules/ws/lib/Receiver.js:360:5)
    at ./node_modules/ws/lib/Receiver.js:462:14

second and after error log:

./node_modules/discord.js/lib/message.js:23
        this.author = this.channel.server.getMember("id", author.id);
                                         ^

TypeError: Cannot read property 'getMember' of undefined
    at new Message (./node_modules/discord.js/lib/message.js:23:36)
    at WebSocket.websocket.onmessage (./node_modules/discord.js/lib/Client.js:876:37)
    at WebSocket.onMessage (./node_modules/ws/lib/WebSocket.js:414:14)
    at emitTwo (events.js:87:13)
    at WebSocket.emit (events.js:172:7)
    at Receiver.ontext (./node_modules/ws/lib/WebSocket.js:797:10)
    at ./node_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (./node_modules/ws/lib/Receiver.js:360:5)
    at ./node_modules/ws/lib/Receiver.js:462:14
    at Receiver.flush (./node_modules/ws/lib/Receiver.js:336:3)
@amishshah
Copy link
Member

Thanks for posting this, I think I can fix it but I will have to do it tomorrow.

Thanks

@amishshah
Copy link
Member

Issue is now fixed! See 3578178. Thanks for bringing it to my attention, you can get the fix by either cloning the repo or just running npm update. It's been released as a bug fix in 3.8.2.

@enebe-nb
Copy link
Contributor Author

Still unresolved, the message.isPrivate is never set, so this.channel.server.getMember()is still being called, causing the same error.

I can make a better debug in private messages once i get some free time.

@amishshah
Copy link
Member

Are you sure? It's fully working here, and isPrivate should be set. Can you state which OS and node version you're running on.

@amishshah amishshah reopened this Oct 10, 2015
@enebe-nb
Copy link
Contributor Author

On Client.js:923 when receiving CHANNEL_CREATE message, it must check if data.is_private == true and call self.addPMChannel instead self.addChannel in this case.

probably you was using same user for tests then the chanel was already created.

@macharborguy
Copy link

same thing happened with me just now. the first private message i sent our bot crashed it out. All messages after were fine. Asked one of our mods to send a PM, this was the first from her, and it crashed the bot, all others after were fine.

So yes, it appears that the first, initial PM to the bot from each user will crash it, as its not processing the PM channel creation properly. After the channel is created (per user), everything is fine. I am using the latest version of Discord.js

./node_modules/discord.js/lib/message.js:27
                        this.author = this.channel.server.getMember("id", author.id) || this.channel.client.getUser("id", author.id);
                                                         ^

TypeError: Cannot read property 'getMember' of null
    at new Message (./node_modules/discord.js/lib/message.js:27:37)
    at WebSocket.websocket.onmessage (./node_modules/discord.js/lib/Client.js:876:37)
    at WebSocket.onMessage (./node_modules/discord.js/node_modules/ws/lib/WebSocket.js:414:14)
    at emitTwo (events.js:87:13)
    at WebSocket.emit (events.js:172:7)
    at Receiver.ontext (./node_modules/discord.js/node_modules/ws/lib/WebSocket.js:797:10)
    at ./node_modules/discord.js/node_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (./node_modules/discord.js/node_modules/ws/lib/Receiver.js:360:5)
    at ./node_modules/discord.js/node_modules/ws/lib/Receiver.js:462:14
    at Receiver.flush (./node_modules/discord.js/node_modules/ws/lib/Receiver.js:336:3)

@enebe-nb
Copy link
Contributor Author

I don't know if hydrabolt published the lasts commits on npm. Can you try to install the lib directly from git?

npm remove discord.js
npm install https://github.com/hydrabolt/discord.js/tarball/master

@amishshah
Copy link
Member

I've not yet been able to push enebe-nb's fixes to npm, I will be able to do so within a few hours

@amishshah
Copy link
Member

Whoops didn't mean to close haha

@amishshah amishshah reopened this Oct 17, 2015
@amishshah
Copy link
Member

The fix has now been pushed to npm (version 3.8.3)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants