此问题在此处已有答案:
TypeError: expected token to be a str, received <class 'NoneType'> instead(3个答案)
15小时前关门了。
我不会修bug
我尝试了一个方法:
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
字符串
我希望它能让机器人在线,但它出现了另一个错误:
Traceback (most recent call last):
File "main.py", line 21, in <module>
client.run(os.getenv('TOKEN'))
File "/home/runner/WhopperBot/venv/lib/python3.10/site-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/runner/WhopperBot/venv/lib/python3.10/site-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/home/runner/WhopperBot/venv/lib/python3.10/site-packages/discord/client.py", line 777, in start
await self.login(token)
File "/home/runner/WhopperBot/venv/lib/python3.10/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
型
我试着重置机器人的令牌,但它一直显示这一个。
1条答案
按热度按时间mm5n2pyu1#
问题似乎出在代币上。它说“期望的令牌是一个str,接收到的是NoneType”。检查以下事项:
1.确保存储令牌的变量被正确地分配给“TOKEN”环境变量的值。你可能在这部分搞砸了。。如何存储变量?
1.重新启动终端或IDE:有时你需要重新启动IDE,这个问题以前也发生过。
1.检查您没有覆盖变量TOKEN。
我建议您首先检查变量TOKEN是否存在
字符串