Json string hiding

I’m making a discord bot on replit and i need to know how do i hide strings in a json file.

here’s how the code looks like:
“clientId”: “i want to hide this”,
“guildId”: “and this”,
“token”: “and this too”
I just want to know if i can hide this in anyway from everyone else since a token is the password and i can’t share it, and if yes, tell me how.

Hey @Senpaqii welcome to the forums!

This is possible. You would use secrets. You can refer to it in the program with process.env.<secret name>.


thanks @Ethan, but can i use “process.env.(secret name)”?

When you login to the bot you would do something like

client.login(process.env.<secret name>)

Well the bot code i use requires me to use a .json file for clientid, guildid, and token and the code doesn’t work unless i put in the information without using secrets

“clientId”: “(process.env.clientid)”,
“guildId”: “(process.env.guildid)”,
“token”: “(process.env.token)”

do i just have to rework the code so it will work?

edit: i found the line responsible for requiring the json file now it works with a secret just had to modify the code a bit so it looks like your second response