I'm a new coder, and I've been following atutorial on how to create a discord bot with the code below having been virtually copied the code straight out from the tutorial, and I've create a .env file to store my AuthToken. Every time I run the code, I get error below aforementioned code. Any tips? Thanks in advance!
Code:
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)
Error:
Traceback (most recent call last): File "/Users/XXXXXXXXXXXX/scratch/discordbot/app.py", line 16, in <module>
client.run(TOKEN) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 640, in run
return future.result() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 621, in runner
await self.start(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 584, in start
await self.login(*args, bot=bot) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 442, in login
await self.http.static_login(token.strip(), bot=bot) AttributeError: 'NoneType' object has no attribute 'strip'
.env
file? – sanitizedUser Jul 1 '20 at 18:05.env
file even though I've got all the updated modules installed. I don't know much, but I can't think of anything else that might be going wrong. – Jake Jul 1 '20 at 18:11DISCORD_TOKEN
and its value. – sanitizedUser Jul 1 '20 at 18:14