Zero6992 / chatGPT-discord-bot

Integrate ChatGPT into your own discord bot
GNU General Public License v2.0
2.6k stars 699 forks source link

TypeError: expected token to be a str, received NoneType instead (I'm not a coder so I'm just following directions) #363

Closed elderprice closed 1 year ago

elderprice commented 1 year ago

I've followed the directions to the T, but it doesn't allow me to start the bot based on the instructions. Upon asking ChatGPT, it says that there is wrong with my discord bot token. However, I literally just copy pasted it. How do I get it to work?

Here's the return after I try to run the bot:

C:\Users\joaqu\Desktop\GPT for Discord\chatGPT-discord-bot-main>python3 main.py 2023-04-23 15:55:12 INFO discord.client logging in using static token Traceback (most recent call last): File "C:\Users\joaqu\Desktop\GPT for Discord\chatGPT-discord-bot-main\main.py", line 30, in bot.run_discord_bot() File "C:\Users\joaqu\Desktop\GPT for Discord\chatGPT-discord-bot-main\src\bot.py", line 296, in run_discord_bot client.run(TOKEN) File "C:\Users\joaqu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 860, in run asyncio.run(runner()) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\asyncio\base_events.py", line 649, in run_until_complete return future.result() File "C:\Users\joaqu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 849, in runner await self.start(token, reconnect=reconnect) File "C:\Users\joaqu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 777, in start await self.login(token) File "C:\Users\joaqu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\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

elderprice commented 1 year ago

raise TypeError(f'expected token to be a str, received {token.class.name} instead') TypeError: expected token to be a str, received NoneType instead

This seems to be the issue. What do I need to change?

Zero6992 commented 1 year ago

It appears that your Python environment is a bit messy, it is recommended to use conda to open a fresh environment for running the program

Zero6992 commented 1 year ago

Please provide your environment btw

elderprice commented 1 year ago

Discord Bot token https://discord.com/developers/applications

DISCORD_BOT_TOKEN=""

Unofficial ChatGPT authentication (only Plus acoount) # https://chat.openai.com/api/auth/session

UNOFFICIAL_PAID=True PUID= ACCESS_TOKEN= OPENAI_EMAIL="" OPENAI_PASSWORD=""

Official GPT-3.5 authentication

OPENAI_API_KEY=""

Bard session_id

BARD_SESSION_ID=

Optional setting

CHAT_MODEL=OFFICIAL # OFFICIAL(OPENAI API), UNOFFICIAL(CHATGPT WEBSITE), Bard, Bing GPT_ENGINE=gpt-3.5-turbo # gpt-4(if you can access GPT-4 models) LOGGING=True REPLYING_ALL=False DISCORD_CHANNEL_ID= # channel using to send the starting-prompt REPLYING_ALL_DISCORD_CHANNEL_ID=

elderprice commented 1 year ago

Is it this one?

elderprice commented 1 year ago

It appears that your Python environment is a bit messy, it is recommended to use conda to open a fresh environment for running the program

I downloaded miniconda - can that work?

And do you mean I use that instead of the command prompt terminal?

Zero6992 commented 1 year ago

Discord Bot token https://discord.com/developers/applications

No, I'm asking you to provide the environment where you execute the code

Zero6992 commented 1 year ago

Did you follow the steps in the README and fill in the information in the .env file?

elderprice commented 1 year ago

Discord Bot token https://discord.com/developers/applications

No, I'm asking you to provide the environment where you execute the code

I just used the Terminal/Command prompt on Windows.

elderprice commented 1 year ago

Did you follow the steps in the README and fill in the information in the .env file?

Yup - I just took out the token and API because it's public.

Zero6992 commented 1 year ago

And you do rename the file to .env right?

elderprice commented 1 year ago

And you do rename the file to .env right?

Yes - actually, when I downloaded your latest file, it's already '.env'.

Although in an earlier version around March, I did see it was 'dev.env' and it had to be renamed.

Zero6992 commented 1 year ago

And you do rename the file to .env right?

Yes - actually, when I downloaded your latest file, it's already '.env'.

Although in an earlier version around March, I did see it was 'dev.env' and it had to be renamed.

No, I think Windows mistakenly recognized that file as having the name .env and the extension dev

You need to create a new text file named .env and copy the contents of the original .env file into it.

elderprice commented 1 year ago

I did that and saved it to a new '.env' file. It still shows the same error as above. Screenshot 2023-04-28 000445

cleaner4 commented 1 year ago

Your .evn file is still a text file you need to rename it by removing the .txt from the end of the name so it says ".env" instead of ".env.txt" ive attached a screenshot showing how it should look notice the file type is "ENV file". Hope this helps. image

elderprice commented 1 year ago

I did that and saved it to a new '.env' file. It still shows the same error as above. Screenshot 2023-04-28 000445

it worked now. Thank you thank you thank you very much!