I don't know how Events works

So, i was trying to make events out of index and i don't know how to make them perfectlly, i tried using the info on docs, but it doesnt leave any error, just don't do anything.
32 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
aquila__.
aquila__.2y ago
messageUpdate should not be a "once" event i believe. try logging before the if statement to see if its running. if its not go back to your event handler and log all your variables to see where a potential issue may be.
treble/luna
treble/luna2y ago
^this and why do you have all the intents? Its not needed. Theres a number of reasons why your update event might not work, the most common ones being * The message might be a partial * The roles might not be cached * You might not have the Guilds intent (which i cannot see because you enabled all intents and srcbin wont let me scroll only enable the intents you need. They decrease resource usage
Dhymbot
DhymbotOP2y ago
at index i have all the intents because at the tutorial put them all, however its reasonable that im not using the most part of these
treble/luna
treble/luna2y ago
delete the ones you are not using
Dhymbot
DhymbotOP2y ago
yeah, im doing it, thanks so, its better to make the messageUpdate on index.js? im going to use console.log() for searching if its detected
aquila__.
aquila__.2y ago
No, you should keep it how it is but set “once” to false and then debug the handler
Dhymbot
DhymbotOP2y ago
ok
aquila__.
aquila__.2y ago
Basically you know how when you start your bot and ready only runs one time.. when the bot starts? That’s when you’d use once but if it’s gonna trigger a bunch, set once to false
Dhymbot
DhymbotOP2y ago
srry if im a bit naive
aquila__.
aquila__.2y ago
it’s okay we all start somewhere
Dhymbot
DhymbotOP2y ago
Ok, i made a few changes like what you said , but still i cannot log information on the module.export. New Index: https://sourceb.in/ScKpg0wvVW Old & New eventHandler: https://sourceb.in/PUsMjpZMtn New messageUpdate: https://sourceb.in/rNTLsjJvFD
treble/luna
treble/luna2y ago
your console.log will error because you do not pass in a string
Dhymbot
DhymbotOP2y ago
omg i literally miss the '' fixed restarting
treble/luna
treble/luna2y ago
i also dont really get why you use switch (folder) { case "client":
Dhymbot
DhymbotOP2y ago
i apologize if that's not the best way to do it, i used a tutorial and do that like showing at my code if this helps, the directories are like this.
index.js \functions | - \handlers | | -eventHandler \events | - \modlog | | -messageUpdate
treble/luna
treble/luna2y ago
why do you have 2 functions folders
Dhymbot
DhymbotOP2y ago
im not focusing bruh im going to dinner, srry if i make more difficult the thing than it should be
treble/luna
treble/luna2y ago
no worries. You appear to switch between folders and search for the client folder, only you dont have a client folder
Dhymbot
DhymbotOP2y ago
uhm, i think i have a client folder, if we mean to the same folder
Dhymbot
DhymbotOP2y ago
Dhymbot
DhymbotOP2y ago
wow, i passed to client folder and there is an error now. It's an advance im fixing the code with the errors thar are appearing however, im using the folder /home/container/events/client, how i can edit the handler for making for each folder? or why doesn't work? Code works perfectly on new folder ✅
treble/luna
treble/luna2y ago
you should just put all your events in an event folder and then read them.with fs
Dhymbot
DhymbotOP2y ago
now i see
Dhymbot
DhymbotOP2y ago
Dhymbot
DhymbotOP2y ago
i think i can change the code with the example on docs, i don't wanna to limit the folders or making anything different
Dhymbot
DhymbotOP2y ago
also this default seems the thing that should apply for a default folder not specified
treble/luna
treble/luna2y ago
default is just what your switch would do if none of your cases match
Dhymbot
DhymbotOP2y ago
that is what i mean
treble/luna
treble/luna2y ago
But you shouldn't blindly follownthe docs
Dhymbot
DhymbotOP2y ago
yes the code im using is from a tutorial at the actual bot, not the docs, just wanna see it for knowing how discordjs web examples did it i delete the switch, now it's working thnx!
Want results from more Discord servers?
Add your server