MongoDB in Discord.js - Trouble accessing database

I’m struggling with this code. The Database connectivity test works, and it connects to the database. However once that code is finished it closes the connection and the data becomes non-accessible. When I copy and paste the same code from the connectivity test to access the database every time I receive a command then it works, HOWEVER it makes the execution time of the very slow compared to usual. Is there a workaround to this issue so I wouldn’t have to open the database every time I receive a new command?

im not sure but for me its like that it connect to the databse but as a user or so? liek when i start a command it do it but nothing change in the db because i need to log in with password and username with the bot i have no idear how to do that sadly(not sure if this help but it could be the problem)