This is my first post, so I apologize if I’ve done something incorrectly.
I’m using Glitch to host a Discord bot and I’m trying to use the env file to hide my bot token. However, whenever I run my bot I get an error saying the variable is an invalid bot token. The bot I am running is Dragory Modmail. I am very inexperienced when it comes to this, so please be aware of that.
Thank you,
Red.
Firstly, just make sure that your scripts are actually able to retrieve the bot token by using console.log() to debug. Do you think you might be mistakened for using the ‘Client Secret’ of your Discord bot and not the ‘Token’ of the bot? I know that alot of people gets mixed up between these two very different things. If you are using the bot token, and the scripts are able to retrieve the token from your .env file, try regenerating your bot token and try again.
Can you be more specific on what you mean by using console.log() to debug?
Also, the token works if I input the token instead of use the variable, so it’s definitely the token.
I haven’t programmed a discord bot in a while but from what I can remember I had to regenerate my token whenever this happened.
I normally regenerated it 2-4 times and then used the new one.
If the token does match with what you have in your .env file, then maybe try regenerating your discord token again and check that your not using the client secret again.
If I open my logs, then my token should pop up there automatically? That’s what happened with me when I opened a new project, coded console.log(process.env.SECRET), and had my token in the .env file.
If I open my logs, then my token should pop up there automatically?
No, console.log(process.env.SECRET) is supposed to tell you what the token is to the log. If you don’t have console.log(process.env.SECRET) in any of your js scripts, your token won’t show up in the logs.
you put process.env.token in config.ini but process.env is for node.js so you need to configure the token in the js file. i’m inexperienced in node. i don’t know anything but i wanted to help