What is the process for setting up a .env file to store my Discord bot token?

I’ve heard that it’s not recommended to keep the Discord Bot token directly in my code as a variable. Instead, it’s suggested to use a .env file. Could someone guide me on how to create this .env file with my token and how to load it into my bot.py script?

Yo! It’s super simple to create. Just make a new file named .env in your project root. Inside, add DISCORD_TOKEN=[your_token_here]. In your script use a library lik dotenv to load it. Don’t forget to add .env to your .gitignore to keep it private.