#Thread regarding the interactions
1 messages · Page 1 of 1 (latest)
Second message
😉
How do you handle your events? So how is the interactioncreate event handled in this case
Is it in your main file as client.on(interactioncreate)?
Or in seperate files
This is the interactionCreate on this bot
ah okay, it's in the same file
Ah okay
No it's in a different file
Then that's not the issue
I meant the event
Apologies for the confusion
When using the "lancerunscenario" command, it calls the function in another file
What is that function?
Yeah that shouldnt cause issues
(To give some context, the bot is a library bot, opening various gamebooks)
So with the slash command, you select a book, in this case "Labyinthe de Sang"
Wait let's do it easy
No none
It's only in one guild, and there are no reactions atm
you should put that messageReactionAdd event in this file as events inside events will make it loop
Wait no that won't work
You could make a counter
In the event handler to count how many times its been called
That way you can see how many times the event was emitted in your console
You could put
let counter = 0
Before the event
And in the event console.log(counter) and in the next line counter++
Also please make sure not to push slash commands at every reboot
There's a limit of 100 global and 100 guild commands per day, it'll get you rate limited. It's annoying
For you*
Epic! Just triggering with a command or a seperate script does the trick
I like to use a command, but many ppl use seperate scripts as you need to reload the bot anyways to add your command handler for the new command into the working bot anyways
Hmm and this all triggers when you boot the bot and then only click a reaction
Can you send your entire main file
the first addMessageReaction entered isn't triggered when the bot reacts
both are triggered when I click
Hmm but you got the type guard now so that's expected
The client.on needs to be in another file
Because it'll work always globally
So you can just add it in main file
your messageReactionAdd event needs to be in the file with your interactionCreate event (maybe below that event?)
I hate how djs explains this crap to new users
Gimme a second to figure out what it means
Okay
I mean, I fully understand what's going on
Just figuring out the implications in this case
Basically event handlers occur once in the main file and listen to events being emitted from. The client
Okay
Feel free to ask if you need anything
by the way, if you don't like a whole spaghetti of event emitters, then you can create an event handler, which spans your events on multiple files (like your command handler). this makes it more readable
That's helpful I'll think about that
Yea that's what I super hate but it does help for some
I'll try to rethink the code and will keep the thread open in the meantime
Thanks a lot to both of you
no problem!
Now it'll fire once
My understanding was that messageReactionAdd was global. So if I started the bot, it would print a "Hello buddy" every time I clicked a reaction in the guild?
For each reaction
But it absolutely doesnt
Hmm what does it do
Yes
And interactions still work?
That looks mighty fine
No typos in the event name messagereactionadd?
Don't see any
Nah nah it's all good
I'll try to figure it out
And will let you know if I find an explanation
Hold up
Yeah?
Old one
Works
So you'd need to fetch the message for it to work on the old one
wow
I'd suggest using buttons over reactions
They always emit interactioncreate no matter if the message was sent 20 years ago
Nono
They emit the same event as a command
I would like to print buttons afgter a messge to let users choose between options
OKOK
You can add buttons like you have the reactions now
Yeah definitely seems like it
And can work with custom ids, which saves you the pain of dealing with all the different reactions
If you need, give me a ping here or hit me up in dms

Sure thing, really appreciate the help!
Creating Your Bot: Event handling