Ruu3f/freeGPT-discord

TypeError: expected token to be a str, received NoneType instead

Closed this issue · 2 comments

Hello. I pasted discord bot TOKEN in .env file and run bot.py but then see error:

2023-08-01 15:52:43 INFO     discord.client logging in using static token
Traceback (most recent call last):
  File "/root/freeGPT-discord-bot/bot.py", line 286, in <module>
    run(bot.run(TOKEN))
        ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/discord/client.py", line 860, in run
    asyncio.run(runner())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/discord/client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "/usr/local/lib/python3.11/dist-packages/discord/client.py", line 777, in start
    await self.login(token)
  File "/usr/local/lib/python3.11/dist-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
Ruu3f commented

Make sure your .env file looks like this:

TOKEN=YOURBOTTOKEN

Replace YOURBOTTOKEN with your bot token.

Ruu3f commented

Actually, I'll just remove .env file so you can simply put your bot token in the bot.py file itself.