eris icon indicating copy to clipboard operation
eris copied to clipboard

TypeError on a MODAL_SUBMIT interaction

Open gamer0mega opened this issue 3 years ago • 10 comments

I'm using client.requestHandler to post the new modals in response to interactions, and when the user submits a modal, i receive this from Eris:

TypeError: Cannot read properties of undefined (reading 'emit')
at Function.from (/root/BruhBot Canary/node_modules/eris/lib/structures/Interaction.js:43:22)
at Shard.wsEvent (/root/BruhBot Canary/node_modules/eris/lib/gateway/Shard.js:2324:60)
at Shard.onPacket (/root/BruhBot Canary/node_modules/eris/lib/gateway/Shard.js:401:26)
at Shard._onWSMessage (/root/BruhBot Canary/node_modules/eris/lib/gateway/Shard.js:2445:29)
at WebSocket.emit (node:events:390:28)
at Receiver.receiverOnMessage (/root/BruhBot Canary/node_modules/ws/lib/websocket.js:983:20)
at Receiver.emit (node:events:390:28)
at Receiver.dataMessage (/root/BruhBot Canary/node_modules/ws/lib/receiver.js:517:14)
at Receiver.getData (/root/BruhBot Canary/node_modules/ws/lib/receiver.js:435:17)
at Receiver.startLoop (/root/BruhBot Canary/node_modules/ws/lib/receiver.js:143:22)
at Receiver._write (/root/BruhBot Canary/node_modules/ws/lib/receiver.js:78:10)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at Receiver.Writable.write (node:internal/streams/writable:334:10)
at TLSSocket.socketOnData (/root/BruhBot Canary/node_modules/ws/lib/websocket.js:1077:35)
at TLSSocket.emit (node:events:390:28)

gamer0mega avatar Feb 09 '22 10:02 gamer0mega

After some more testing, the issue appears only on this type of interaction. [email protected] (git+ssh://[email protected]/abalabahaha/eris.git#1a6e043331aea04de307a71d2e50e9680d1a5ae3)

gamer0mega avatar Feb 09 '22 10:02 gamer0mega

The issue is that Eris doesn't have a type for Modals yet, so it can't return an interaction of that type. See lib/structures/Interaction.js

coolcalcacol avatar Feb 09 '22 11:02 coolcalcacol

PR will be created in due course. Ignore my last reply if you saw it

bsian03 avatar Feb 09 '22 11:02 bsian03

The issue is that Eris doesn't have a type for Modals yet, so it can't return an interaction of that type. See lib/structures/Interaction.js

Why can't it just create a default interaction then? It isnt that hard to make image

gamer0mega avatar Feb 09 '22 17:02 gamer0mega

There was supposed to be UnknownInteraction for this since the type of modal interaction differs.

doomestee avatar Feb 09 '22 17:02 doomestee

There was supposed to be UnknownInteraction for this since the type of modal interaction differs.

So it didn't work?

gamer0mega avatar Feb 09 '22 17:02 gamer0mega

UnknownInteraction is still a thing on latest dev.

TypeError: Cannot read properties of undefined (reading 'emit')
at Function.from (/root/BruhBot Canary/node_modules/eris/lib/structures/Interaction.js:43:22)
...

In the commit you referenced, 1a6e043331aea04de307a71d2e50e9680d1a5ae3, the line originating your error doesn't do anything like that. Try testing with latest npm release?

https://github.com/abalabahaha/eris/blob/1a6e043331aea04de307a71d2e50e9680d1a5ae3/lib/structures/Interaction.js#L43

eritbh avatar Feb 09 '22 17:02 eritbh

I've actually poked around the WS event, the error was that when the Shard receives the WS EVENT for INTERACTION_CREATE, it uses Interaction.from(interaction, client) to create an Interaction object, however the Interaction.from is trying to use this._client which is impossible since it's a static function, and hasn't been initialised so there's no such thing as that..

https://github.com/abalabahaha/eris/blob/dev/lib/gateway/Shard.js#L2334 https://github.com/abalabahaha/eris/blob/dev/lib/structures/Interaction.js#L46

doomestee avatar Feb 09 '22 17:02 doomestee

oh, duh, that makes sense. Since client is passed in that method, should be an easy PR to fix it; I'll do it later tonight if nobody beats me to it.

edit: Issue fixed by #1334

eritbh avatar Feb 09 '22 17:02 eritbh

what is going on with my ipad this is still of relevance, and will be closed when a new release is made

bsian03 avatar Feb 13 '22 23:02 bsian03