r/pythonhelp • • Apr 07 '22

Cant figure out discord bots.

I'm trying to make a discord bot but it won't work. I took the code from a website that's meant to help but it won't work for some reason, here's the code:

# bot.py
import os
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
client.run(TOKEN)

0 Upvotes

3 comments sorted by

1

u/carcigenicate Apr 07 '22

What doesn't work exactly? Do you get an error? You need to give sufficient detail for people to be able to help you.

1

u/EldenRing_Bot Apr 08 '22

Oh right, it says:

no module name "dotenv"

1

u/EldenRing_Bot Apr 08 '22

I fixed that, now I get

AttributeError: 'NoneType' object has no attribute 'strip'