Ask coding questions

← Back to all posts
The code is runned twice...
TinchoDS (1)

Hello, i dont whats happening with Repl.it, i know it's not my code, cuz i runned it on visual studio code, and it works fine. But, when i Run it here, it runns twice and i have to comment the server part, cuz it gets an error for trying to execute a server on the same port...

Comments
hotnewtop
KHZ (122)

@TinchoDS First of all you should immediately remove your bot token out of your visible repl as the whole world can see it!

Well not really the Whole World
But the whole repl community

You should first move your bot token to the separate file named .env. In this file you should write the token like this:
TOKEN=Nzk4MzI1ODMxMjczMTUyNTEy.X_

BTW this is not the whole token

Then in your bot file at the end you should run the bot like this:
Client.login(process.env.TOKEN)

KHZ (122)

@KHZ Oh and I don't know the answer of your solution but I needed to point this fact out and what I do think is that the bot shouldn't be able to run twice. And if you are not talking about this repl then pin the right repl.

KHZ (122)

@KHZ Sorry after running it I did see that the program ran twice as it outputted the login message twice. Hence I don't know your problem. Hopefully someone skillful will help you with it.