Problems in developing a discord bot

I really need help((

This is my code:

and I got the error:

Traceback (most recent call last):
File “c:\Users\User\Desktop\python_work\main.py”, line 19, in
client.run(os.getenv(‘TOKEN’))
File “C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py”, line 860, in run
asyncio.run(runner())
File “C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py”, line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File “C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py”, line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py”, line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File “C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py”, line 849, in runner
await self.start(token, reconnect=reconnect)
File “C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py”, line 777, in start
await self.login(token)
File “C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py”, line 609, in login
raise TypeError(f’expected token to be a str, received {token.class.name} instead’)
TypeError: expected token to be a str, received NoneType instead
PS C:\Users\User>

I created a .env file besides main.py, and I thought if I ran main.py, it would connect .env file, and my bot could be alive. However, it still didn’t work.

Related software developing applications

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.