No more .env files in Replit

I was following a tutorial on how to create a discord bot ( this one ) but the problem is that Replit no longer lets you create your own .env files.

Which was kind of tricky to me since I’m still a beginner in JS. I tried pasting the bot ID into the “Key” field and the value (secret key) into the “Key” field but had no luck.

I also tried adding the TOKEN= before the value but just kept returning different errors.

I saw other threads here but they weren’t about this specific discord tutorial so following along was hard.

May be this will solve you issue

HI @Zeek1337 !

Welcome to the forum!

Edit: I am using the token from the video just to demonstrate how to use the new env file setup in replit. If you want to connect with your discord bot then you will use the value you created through discord.

Here is what you have to do.

Step1 :Open up the secrets tab

Step 2: You are going to add the KEY and value.

Step 3: Click on Add new secret.

Step 4: Click insert.

Step5: You should see the variable of mySecret at the bottom of index.js Add that variable into the client.login like shown below.

Step 6: Hit run and you should see this as the output

Hope that helps!

2 Likes

I just literally had the same issue, did you get it solved as I can help if you want?

1 Like

here’s a screenshot

Thanks for your detailed answer.
I created a new replit and followed the same steps but I got the same error.

I triple checked the key and value fields so I’m not sure what I’m doing wrong.

Again, I appreciate your time

Not yet, I followed @jwilkins.oboe 's steps but I’m still getting an error

you need to use the Token of your bot, not the token in the video. It says invalid token, because it is not the correct one

I used the value from the video and it worked for me. But maybe we can try generating a new one. :woman_shrugging:

But if the camper wanted to use this discord bot outside of a class project then it would be better to have their own secret token.

Let’s try getting a new token

You want to go to the 2 minute mark of the video where they start to talk about creating a token.

Then you can try adding that to your application and see if it works.

I figured it out. I was not copying the token of the bot, I was copying something else called client secret.

Anyway thanks for the help everyone

I didn’t use the one in the video… I’m obviously not going to type it all in. I used mine from the discord application developer site. It’s all copy and pasted anyway from the “copy” buttons, so I’m 100% sure there are no “spelling” mistakes token wise.

1 Like

please share your repl, the environment variable are visible only to you so you can share the link without worrying about sharing your token

@jwilkins.oboe Hi when you say the Value in the secrets is exact do you want us to copy the TOKEN given by Discord or do we have to input what you wrote?

if you want the script to connect with your bot you need to use the token given by Discord to you

Hi @AKMC603 !

Welcome to the forum!

Both will work, but as mentioned if you want your own discord bot then you will use the token you created at minute 2 of the video.

I’ll edit my earlier response to let people know that.

ok so we basically need to -
go to Secrets then in key type TOKEN and then in value type the Discord bot token, right?

1 Like

Yep that’s correct.

I would just copy and paste the value of your bot instead of typing it out.
That way you don’t run into errors.

1 Like

A post was split to a new topic: Help with python discord bot

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.