Why isnt a public endpoint needed on discord.js ?

When developing using discord api (without discord.js library) by itself, per their guides, a public url is needed so the requests can be sent. This is done by either using glitch or ngrok to expose your localhost via tunneling. My question is: Why when using discord.js a public endpoint isnt needed and you can run the bot locally without the need to expose your localhost ? How does their API connect to your localhost ? I have asked this on discord developers but im probably too dumb to understand the answers I got.
DT
d.js toolkit198d 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!