#I AM NEW IN PYTHON AND MY BOT DOESNT WORKS

1 messages · Page 1 of 1 (latest)

loud cosmosBOT
#

Saying it doesn't work or asking what's wrong with this code is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

#

When setting up your bot, avoid hardcoding your token directly in the code. Instead, use environment variables:

  • Install python-dotenv with pip install python-dotenv.
  • Create a .env file at the root of your project.
  • Add your token to the .env file: TOKEN=<your bot token>.
  • Use the token in your code as follows:
import discord
import os
from dotenv import load_dotenv

load_dotenv()

bot = discord.Bot()

# Your code here

bot.run(os.getenv("TOKEN"))