Reaction Listener bot help needed

I have this bot that I want to do these things. I want it to send an embed on command, react to it, then listen to user reactions and log those reactions in another channel. Things I am having trouble figuring out is: 1. the embed sends twice when the command is sent for what i have no idea 2. i would like to make it so that the user can only input one reaction at a time. so that if a user changes their reaction, their old one is removed. 3. i would like the bot to automatically remove any reactions that are not the same emoji as the ones the bot reacted to itself with. Any help is appreciated. I am brand new to v14 and I am having trouble figuring this out, so talk to me like I know nothing. Thank you!
No description
23 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
probablyraging
probablyraging4mo ago
1. Are you only running 1 instance of the bot? 2. You can get a cache of message reaction users with message.reactions.cache.users, see if the users who reacted to the new reaction has previously reacted to any other reactions, you can remove their other reactions with message.reactions.cache.users.remove() 3. Use the messageReactionsAdd event to see if the reaction is being added to your embed, and if it's not a reaction you want added, remove it with messageReaction.remove() Further, on the third line, it should be message.author.id !== '00000000' because !message.author will always be false. I assume that ID is your bot ID and you want it to not reply to itself?
SilverStorm
SilverStorm4mo ago
that third line is just i want to be the only person able to use the command yes, i think im only running one instance, i just node . when i need to test something do you think you could write small code snippets as examples? i cant find resources on this and because of how new i am im not able to write completely on my own yet. sorry if im asking too much @probablyraging 🍄
probablyraging
probablyraging4mo ago
Right, I get that, but your condition is incorrect (!message.author === '00000000') - is basically saying "if message.author is false and equal to '0000000' then return" which is not doing what you want it to do because that statement !message.author is always going to false so the entire condition will always be false (message.author.id !== '0000000' - is saying "if message.author.id is not equal to '0000000'" then return" which is what you want it to do
== equal to
=== equal value and equal type
!= not equal
!== not equal value or not equal type
> greater than
< less than
>= greater than or equal to
<= less than or equal to
? ternary operator

&& logical and
|| logical or
! logical not
== equal to
=== equal value and equal type
!= not equal
!== not equal value or not equal type
> greater than
< less than
>= greater than or equal to
<= less than or equal to
? ternary operator

&& logical and
|| logical or
! logical not
No I'm not going to write your code for you
SilverStorm
SilverStorm4mo ago
okay, well this helps any idea on why the embed sends twice or no? based off the code already written
probablyraging
probablyraging4mo ago
Only thing I can assume is either the incorrect condition or you've got 2 instances running somehow
SilverStorm
SilverStorm4mo ago
alright, i'll troubleshoot those two things
d.js docs
d.js docs4mo ago
:property: MessageReaction#users A manager of the users that have given this reaction :method: ReactionUserManager#remove() Removes a user from this reaction. :event: (event) Client#messageReactionAdd Emitted whenever a reaction is added to a cached message.
probablyraging
probablyraging4mo ago
Those links should help too. I'll be around for a while so have a crack at it yourself and if you need help, just ping me
SilverStorm
SilverStorm4mo ago
sounds good
SilverStorm
SilverStorm4mo ago
yeah i dont know what the hell i did but now the bot wont send ANYTHING at all
No description
SilverStorm
SilverStorm4mo ago
or even console log that its recieved anything @probablyraging 🍄 i havent changed really anything... just tried fixing the issue where it was sending twice i closed every instance and now after i restarted it, nothing happens i checked and the user id isnt wrong
probablyraging
probablyraging4mo ago
message.author.id not message.author Line 5
SilverStorm
SilverStorm4mo ago
oh for fucks sake it sends the embed only once now, but now it doesnt add its reactions
probablyraging
probablyraging4mo ago
Should full code again, use https://pastebin.com/
Pastebin
Pastebin.com - #1 paste tool since 2002!
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
SilverStorm
SilverStorm4mo ago
Pastebin
code - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
probablyraging
probablyraging4mo ago
Can't see anything wrong with that, does the bot have perm to add reactions?
SilverStorm
SilverStorm4mo ago
it does it was working just a bit ago i fixed it by changing it to this
await PvP.react(':crossed_swords:');
await PvP.react(':peace:');
await PvP.react(':crossed_swords:');
await PvP.react(':peace:');
instead of having it on one line which is annoying that i had to do this
probablyraging
probablyraging4mo ago
Oh yeah, I just seen you were using [] brackets instead of () on PvP.react, react is a function so should be react('🧁') for example
SilverStorm
SilverStorm4mo ago
ah i see what function would i use if i wanted to just have my code wait like 10 seconds before sending the log in the other discord channel? @probablyraging 🍄 i swear i thought it was setTimeout but that isnt working
probablyraging
probablyraging4mo ago
You can use setTimeout
d.js docs
d.js docs4mo ago
:mdn: setTimeout() global function The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires.
probablyraging
probablyraging4mo ago
If you mean you want the rest of the code to wait before executing, you can use setTimeout in a Promise Like so new Promise(resolve => setTimeout(resolve, 1000))