Skip to main content
ChimBot requires several environment variables to function properly. This page covers all required and optional configuration variables.

Required Variables

TOKEN
string
required
Your Discord bot token from the Discord Developer Portal
Never share your bot token publicly or commit it to version control
GROQ_API_KEY
string
required
Your Groq API key for AI-powered responses using LLaMA 3.3 70BGet your API key from Groq Console

Setup

Create a .env file in the root directory of your bot:
.env
TOKEN=your_discord_bot_token_here
GROQ_API_KEY=your_groq_api_key_here
The .env file is already included in .gitignore to prevent accidental commits. Keep your tokens secure.

Loading Environment Variables

ChimBot uses python-dotenv to load environment variables automatically at startup:
main.py
from dotenv import load_dotenv
import os

load_dotenv()

# Access environment variables
GROQ_API_KEY = os.getenv('GROQ_API_KEY')
The bot loads these variables when main.py starts running (line 11).

Getting Your Discord Token

1

Go to Discord Developer Portal

Visit discord.com/developers/applications and create a new application
2

Create a Bot

Navigate to the “Bot” section and click “Add Bot”
3

Copy Token

Under the token section, click “Reset Token” and copy the generated token
This token will only be shown once. Save it securely.
4

Enable Privileged Intents

Enable the following intents:
  • Message Content Intent
  • Server Members Intent

Getting Your Groq API Key

1

Create Groq Account

Sign up at console.groq.com
2

Generate API Key

Navigate to API Keys section and create a new key
3

Copy Key

Copy the generated API key and add it to your .env file

Validation

To verify your environment variables are loaded correctly:
import os
from dotenv import load_dotenv

load_dotenv()

if not os.getenv('TOKEN'):
    print("ERROR: Discord TOKEN not found")
    
if not os.getenv('GROQ_API_KEY'):
    print("ERROR: GROQ_API_KEY not found")
    
print("Environment variables loaded successfully")

Security Best Practices

Use .env files

Store all sensitive credentials in .env files, never in source code

Add to .gitignore

Ensure .env is in your .gitignore file to prevent commits

Rotate keys regularly

Periodically regenerate your API keys and tokens

Limit permissions

Only grant the minimum required Discord permissions

Troubleshooting

  • Verify .env file exists in the same directory as main.py
  • Check that python-dotenv is installed: pip install python-dotenv
  • Ensure there are no spaces around the = in your .env file
  • Verify the variable name is exactly TOKEN (case-sensitive)
  • Confirm your Groq API key is valid and active
  • Check the variable name matches exactly: GROQ_API_KEY
  • Verify you’ve copied the entire key without truncation
  • Verify both environment variables are set correctly
  • Check the bot has proper Discord permissions
  • Ensure privileged intents are enabled in Discord Developer Portal
  • Review the console for error messages

Next Steps

Customize Bot Behavior

Configure personality, spam detection, and more

Set Permissions

Learn about required Discord permissions

Build docs developers (and LLMs) love