Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Stentorian

Node.JS Error

On 5/14/2019 at 12:37 PM, Breadpudding said:

Your if statement on line 8 isn't checking if the variable is equal to true. It's setting the value to true instead. If the value is a boolean, simply make it:


if(bot) return;

Also about detecting which emoji you're placing: Don't use emoji in your code. There's a reference about using emoji with discord.js here: https://discord.js.org/#/docs/main/stable/class/ReactionEmoji

Maybe name isn't what you think it is? Try logging the result of getting the emoji's name to see if it prints something similar to "regional_indicator_k". I haven't dealt with reactions myself but it's worth a shot.

 

On 5/11/2019 at 8:35 PM, duncannah said:

Are you sure reaction.emoji.name matches what you're comparing it to? Try comparing it to the name that is labelled in the emoji picker instead:

image.png.9aded81d8bfed03264fea2b079f4fe5b.png

I've just given up on using a reaction system and I've just gone to sub-commands. Thanks for the help though! 

Recommended Posts

Posted · Original PosterOP

Hello, 

 

I am trying to create a sponsor command for my public Discord bot but I want to make it interactive so that when a user reacts to the message with the corresponding emoji, it will send the embed. I have removed the embeds for privacy reasons but I need some help. Refer to the code and error below. 

 

CODE: https://hasteb.in/ugaxoqen.js

ERROR: https://hasteb.in/decegova.coffeescript

 

Many Thanks. 

Ben

Link to post
Share on other sites

Remove ".message" from here:
image.png.8f4cbe442285144557cb12e9d92b9928.png

 

Since the users property is part of MessageReaction class, not Message.


( ・∀・)・・・--------☆

Link to post
Share on other sites
Posted · Original PosterOP
1 hour ago, duncannah said:

Remove ".message" from here:
image.png.8f4cbe442285144557cb12e9d92b9928.png

 

Since the users property is part of MessageReaction class, not Message.

I now get this error message: 

(node:19680) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'bot' of undefined
    at collected.forEach.reaction (C:\Users\stent\Documents\GitHub\StenBot\commands\sponsors.js:43:43)
    at Map.forEach (<anonymous>)
    at message.awaitReactions.then.collected (C:\Users\stent\Documents\GitHub\StenBot\commands\sponsors.js:42:27)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:19680) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,
or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19680) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

 

Link to post
Share on other sites

Maybe reaction isn't in the format you think it is, console log reaction and take a look


                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites
Posted · Original PosterOP
13 minutes ago, vorticalbox said:

Maybe reaction isn't in the format you think it is, console log reaction and take a look

I console log'd reaction and got this https://hasteb.in/yixigiyu.yaml

 

What I am trying to do is set up the bot so it ignores itself when reacting to a message which is why the bot thing is there. 

Link to post
Share on other sites
2 hours ago, Stentorian said:

So I've got it semi-working. https://hastebin.com/otidizosec.js

 

The only problem now is that nothing happens when I react to the message. No errors at all. 

line 25, 

                if (bot = true) return;

I'm guessing you meant:

if (bot !== true) return;

 

Link to post
Share on other sites

The users property is a Collection so you'll need to do:

if (reaction.users.first().bot) bot = true;

 


( ・∀・)・・・--------☆

Link to post
Share on other sites
Posted · Original PosterOP
18 hours ago, elpiop said:

line 25, 


                if (bot = true) return;

I'm guessing you meant:


if (bot !== true) return;

 

No. I need it to ignore when the bot reacts to the message at the start so it doesn't get triggered by that and instead when a user reacts. 

 

12 hours ago, duncannah said:

The users property is a Collection so you'll need to do:


if (reaction.users.first().bot) bot = true;

 

So I've changed it to this https://hasteb.in/opusoxay.js following what you said and now whenever I react to the message, nothing happens. Nothing in the console either.

Link to post
Share on other sites
1 hour ago, Stentorian said:

So I've changed it to this https://hasteb.in/opusoxay.js following what you said and now whenever I react to the message, nothing happens. Nothing in the console either.

Are you sure reaction.emoji.name matches what you're comparing it to? Try comparing it to the name that is labelled in the emoji picker instead:

image.png.9aded81d8bfed03264fea2b079f4fe5b.png


( ・∀・)・・・--------☆

Link to post
Share on other sites

Your if statement on line 8 isn't checking if the variable is equal to true. It's setting the value to true instead. If the value is a boolean, simply make it:

if(bot) return;

Also about detecting which emoji you're placing: Don't use emoji in your code. There's a reference about using emoji with discord.js here: https://discord.js.org/#/docs/main/stable/class/ReactionEmoji

Maybe name isn't what you think it is? Try logging the result of getting the emoji's name to see if it prints something similar to "regional_indicator_k". I haven't dealt with reactions myself but it's worth a shot.


Discord: Breadpudding#9078

GitHub: https://github.com/cbpudding

Programming Guild: https://discord.gg/7ZVbxXT

Link to post
Share on other sites
Posted · Original PosterOP · Best Answer
On 5/14/2019 at 12:37 PM, Breadpudding said:

Your if statement on line 8 isn't checking if the variable is equal to true. It's setting the value to true instead. If the value is a boolean, simply make it:


if(bot) return;

Also about detecting which emoji you're placing: Don't use emoji in your code. There's a reference about using emoji with discord.js here: https://discord.js.org/#/docs/main/stable/class/ReactionEmoji

Maybe name isn't what you think it is? Try logging the result of getting the emoji's name to see if it prints something similar to "regional_indicator_k". I haven't dealt with reactions myself but it's worth a shot.

 

On 5/11/2019 at 8:35 PM, duncannah said:

Are you sure reaction.emoji.name matches what you're comparing it to? Try comparing it to the name that is labelled in the emoji picker instead:

image.png.9aded81d8bfed03264fea2b079f4fe5b.png

I've just given up on using a reaction system and I've just gone to sub-commands. Thanks for the help though! 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×