bug: MessageReact event crashes with: TypeError: reactions.get is not a function
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, typescript
- Domain
- api
Research direction
Start at the MessageReact handler shown in the issue and inspect how message.reactions is updated when the messageReactionAdd listener runs after clearReactions. Reproduce the sequence with clearReactions followed by react, then verify that the event no longer crashes when reactions is an object rather than a Map.
Written by the indexing model from the issue text.
Description
What happened?
This snippet of code causes the above error:
case 'MessageReact': {
const message = client.messages.getOrPartial(event.id);
if (message) {
const reactions = message.reactions;
const set = reactions.get(event.emoji_id);
... when a messageReactionAdd event listener exists:
// ...
this.options.client.on('messageReactionAdd', this.listener);
// ...
This code was used to trigger the error:
await msg.clearReactions();
await msg.react(encodeURIComponent('❌'));
Explanation: The event tries to get which reaction was added (?), but, since clearReactions ran, message.reactions is {}, causing the reactions.get is not a function error, since reactions is not a Map anymore.
My temporary fix:
case 'MessageReact': {
const message = client.messages.getOrPartial(event.id);
if (message) {
let reactions = message.reactions;
if (!(reactions instanceof Map)) reactions = new Map();
const set = reactions.get(event.emoji_id);
- Dominant language
- TypeScript
- Stars
- 285
- Forks
- 108
- Avg merge
- 16h 49m
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stoatchat/javascript-client-sdk
-
bug good first issue
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
no login Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
stoat.js does not detect the MessageUpdate clear field, causing messages to stay pinned until reload Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
stoatchat/javascript-client-sdk#155 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
stoatchat/javascript-client-sdk#139 · 2 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
stoatchat/javascript-client-sdk#132 · 2 comments ·
All issues in stoatchat/javascript-client-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
area:tools bug good first issue help wanted priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
TaewoooPark/Motifcode#14 ·
-
bug 🐞
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
[Bounty proposal] fix(web): memory insights count an evening memory on the next day ($25 proposed) Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
BasedHardware/omi#15320 ·
-
Difficulty 2/5 Half a day Newbie friendliness 78/100
vercel/vercel-plugin#199 ·