Cke_dvgz
Cke_dvgz

Reputation: 39

discord.js reactions TypeError: Cannot read property 'get' of undefined

So i was trying to collect reactions from an embed but im still getting this error:

      var peopleReacted = embedsend.reactions.get(party).users.array();
                                              ^

TypeError: Cannot read property 'get' of undefined
    at Timeout._onTimeout

Here's my code:

message.channel.send(`${boost} **GIVEAWAY** ${boost}`, embed).then(sentEmbed => {
  sentEmbed.react(party)});
      
    setTimeout(function() {

      var random = 0;
      var winners = [];
      var inList = false;

      var peopleReacted = embedsend.reactions.get(party).users.array();

I've also been trying using sentEmbed.reactions.get or cache.get but then i get sentEmbed is not definied

Upvotes: 0

Views: 49

Answers (1)

Yankue
Yankue

Reputation: 378

One of the errors is in embedsend.reactions.get(party).users.array();, because (assuming u're in d.js version 12), you must instead use .cache, so make it embedsend.reactions.cache.get(party).users.array();

Also, var embedsend = embed; is not a message, it is an embed object. Instead, use var embedsend = message.channel.send('${boost} **GIVEAWAY** ${boost}', embed);, then it will be set to the actual message you sent, rather than the embed.

Upvotes: 1

Related Questions